#!PERLPROG
#	rndarg
#	by Paul Balyoz
#
#	Output all command-line arguments passed in, but in a random order,
#	one argument output per line.
#

#	$DEBUG=1;			# uncomment for debugging output

	local($i,$pos);
	local(@argp,$tmpp);

# Seed random number generator in a fairly good way

	srand(time | $$<<5);

# Create modifiable list of argument strings

	for ($i=0; $i<=$#ARGV; $i++) {
		$argp[$i] = $ARGV[$i];
	}

# Randomly rearrange argument strings

	for ($i=0; $i<=$#ARGV; $i++) {
		$pos = int(rand($#ARGV+1));
		if ($DEBUG) {
			print "$i swap with $pos\n";
		} else {
			$tmpp = $argp[$pos];
			$argp[$pos] = $argp[$i];
			$argp[$i] = $tmpp;
		}
	}

# Now print the randomized arguments each on separate lines

	for ($i=0; $i<=$#ARGV; $i++) {
		print "$argp[$i]\n";
	}

	exit 0;
