in reply to Randomising the order of an array
What about
use List::Util qw( shuffle ); my @jumpedArray = map { $dataArray[$_*2+0], $dataArray[$_*2+1] } shuffle 0 .. @dataArray/2-1;
Off topic: Wouldn't it be easier if your data was organized as follows:
my @dataArray = ( [ \@inputValue1, \@outputValue1 ], [ \@inputValue2, \@outputValue2 ], ... );
That would eliminate any unsightly $_*2+0 and $_*2+1 you have in your code. For example, the shuffling would simplify to the following:
use List::Util qw( shuffle ); my @jumpedArray = map { $dataArray[$_] } shuffle 0 .. $#dataArray;
Update: oops, I was doing a straight copy. Fixed.
|
|---|