shuffle( \@array ); sub shuffle { my $array = shift; for ( my $i = 0; $i <= $#array; ++$i ) { my $rand = rand($#array); @$array[$i,$rand] = @$array[$rand,$i]; } }
{Editor's note: This solution is flawed. Read Abigail-II's reply, Re: Answer: How do I shuffle an array?, for an explanation.}
In reply to Re: How do I shuffle an array?
by rajib
in thread How do I shuffle an array?
by vroom
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |