There are always old-school C-style loops:
use strict; use warnings; my @array = ( 0 .. 50 ); for ( my $idx = 0; $idx <= $#array; $idx += 20 ) { my $top = $idx + 19; $top = ( $top <= $#array ) ? $top : $#array; print "Processing elements $idx through $top.\n"; foreach my $element ( @array[ $idx .. $top ] ) { # Process each $element here. ...for example... print $element, " "; } print "\n\tDone with $idx through $top.\n\n"; }
Dave
In reply to Re: Working Through An Array In Chunks
by davido
in thread Working Through An Array In Chunks
by Cody Pendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |