in reply to Making little array babies
Here's one (untested) way...
my @images = qw/IMAGE1 IMAGE2 IMAGE3 IMAGE4 IMAGE5 IMAGE6 IMAGE7 IMAGE8 IMAGE9 IMAGE10 IMAGE11/; my @lol; while ( @images ) { push @lol, [ map { (@images) ? shift @images : undef } 1..3 ]; }
An artifact of this method is that if your initial array has a number of elements not evenly divisible by three you'll get one or two final elements that equate to undef in the last element in @lol.
Dave
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Making little array babies
by nmcfarl (Pilgrim) on Apr 12, 2004 at 11:18 UTC | |
by vaya11 (Initiate) on Apr 14, 2004 at 00:49 UTC |
In Section
Seekers of Perl Wisdom