# randomly permute an array @a
for (my $i=$#a; $i>0; $i--) {
    my $j = int rand ($i+1);
    @a[$i,$j] = @a[$j,$i];
}
