in reply to Randomize elements among several arrays, while maintaining original array sizes.
I'm still not sure what you're trying to do.. but you might want to checkout perldoc -q shuffle@b = ( @a, 11, 32 ); my ( @newa, @newb, @newc ); my @sizes = ( scalar(@a), scalar(@b), scalar(@c) ); my @where_to = qw/a b c/;
UPDATE I believe the op just now clarified what about something like this, using parallel assignment:use List::Util 'shuffle'; @shuffled = shuffle(@list);
use XXX; use List::Util; @a=qw/foo bar baz/; @b=qw/mickey/; @c=qw/x y z/; (@a[0..$#a],@b[0..$#b],@c[0..$#c]) = List::Util::shuffle(@a,@b,@c); XXX [\@a, \@b, \@c]'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Randomize elements among several arrays, while maintaining original array sizes.
by EvanK (Chaplain) on Aug 01, 2008 at 16:40 UTC | |
by BioNrd (Monk) on Aug 01, 2008 at 16:50 UTC |