#!/usr/bin/perl
# bgrandom.pl
# Randomizes the file list
# See the file LICENSE in the main distribution for license info
# Written by Matthew Fuller <fullermd@over-yonder.net>


use Env;

srand;
$lines = 0;
open(MASTERLIST, "$DATADIR/master.background.list") ||
		die "master list: $!";

while (<MASTERLIST>) {
	chomp;
	push(@sorted, $_);
	$lines += 1;
}

$totalines = $lines;

while ($lines > 0) {
	$randno = int(rand $totalines);
	while(($desorted[$randno])) {
		$randno = int(rand $totalines);
	}
	$desorted[$randno] = pop(@sorted);
	$lines --;
}

foreach (@desorted) {
	print $_;
	print "\n";
}
