for more read perldoc -q shuffle.sub fisher_yates_shuffle { my $deck = shift; # $deck is a reference to an array my $i = @$deck; while ( $i-- ) { my $j = int rand( $i + 1 ); @$deck[ $i, $j ] = @$deck[ $j, $i ]; } } my @aa = qw/a b c d e f/; fisher_yates_shuffle( \@aa );
In reply to Re: shuffle array (in place)
by borisz
in thread shuffle array (in place)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |