BramVanOosterhout has asked for the wisdom of the Perl Monks concerning the following question:
--$i is calculated before entering the body. And rand($i + 1) will never return the value of $i.
The loop control that works is:
for ( my $i = @$array; $i; $i-- ) {
This was originally posted as an Answer to the Categorized Question How do I shuffle an array?. It was removed from the CatQA section because it is not a good answer.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I shuffle an array?
by AnomalousMonk (Archbishop) on Jul 10, 2017 at 07:08 UTC |