in reply to Traversing succeding sets of an array
or, with a counter:my $elementsToGet = 2; # how many elements shell be in @sublist my @newElements = @elements; while (my @subList = splice(@newElements, 0, $elementsToGet)) { # do something with @subList } # while Beware that @newElements might be empty after the while...
I haven't tested these codes.for (my $i=0; $i<=$#elements; $i+=2) { # do something with $elements[$i] and $elements[$i+1] } # for
Best regards,
perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Traversing succeding sets of an array
by very empty (Scribe) on May 14, 2002 at 16:13 UTC |