Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
sub shuffle { my $array = shift; my $i = @$array; while ( --$i ) { my $j = int rand( $i+1 ); @$array[$i,$j] = @$array[$j,$i]; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array shuffle code produces 'Modification of non-creatable array value attempted' error
by toolic (Bishop) on May 29, 2015 at 18:27 UTC | |
|
Re: Array shuffle code produces 'Modification of non-creatable array value attempted' error
by Anonymous Monk on May 29, 2015 at 19:42 UTC | |
|
Re: Array shuffle code produces 'Modification of non-creatable array value attempted' error
by stevieb (Canon) on May 29, 2015 at 18:48 UTC | |
|
Re: Array shuffle code produces 'Modification of non-creatable array value attempted' error
by ikegami (Patriarch) on Jun 01, 2015 at 16:45 UTC |