this algorithm for shuffling arrays is called Fisher-Yates
shuffling, i shamelessly pasted it from the Perl Cookbook :)
sub shuffle {
my $arr = shift;
my $x;
for ($x = @$arr; --$x; ) {
my $y = int rand ($x+1);
next if $x == $y;
@$arr[$x,$y] = @$arr[$y,$x];
}
}
shuffle(\@array);