in reply to Making little array babies
It's also really simple. :-)my @a = qw( a b c d e f g ); my $n = 3; my @b; for ( my $i = 0; $i <= $#a; $i += $n ) { push @b, [ @a[ $i .. $i+$n-1 ] ]; }
jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Making little array babies
by revdiablo (Prior) on Apr 12, 2004 at 21:50 UTC | |
by jdporter (Paladin) on Apr 13, 2004 at 13:51 UTC |