in reply to printing certain number of data
perldoc -f splice. Keep in mind this is destructive so you might want to do the splicing to a copy rather than your original if you need to use the source array again later.
my @src = 'a' .. 'zz'; my $count = 0; while( my @cur = splice( @src, 0, 8 ) ) { print join( "\t", @cur ), "\n"; $count += @cur; last if $count >= 40; }
Update: Clarified warning.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: printing certain number of data
by drock (Beadle) on Jul 01, 2004 at 16:49 UTC | |
by Fletch (Bishop) on Jul 01, 2004 at 18:27 UTC | |
by Not_a_Number (Prior) on Jul 01, 2004 at 17:28 UTC |