Array::Slice - context-dependent array iterator
By Dmitry Karasik (McFist) from Copenhagen.pm Lightning talk Language: I've always wanted the power of foreach(@arr) to be applied to arrays working with more than one item at a time. Perl6 does it, Perl5 with source filtering can do it, close, but no cigar. This module is an small step towards the idea, an attempt to produce a way of slicing a single array with least obtrusive syntax I can think of. Now, you can iterate over an array assigning several items per cycle, by
three items at once:
while ( my ( $x, $y, $z) = slice @arr) { ... }
or two,
while ( my ( undef, $second) = slice @arr) { ... }
or even forty-two:
while ( @a = slice @arr, 42) { ... }
URL: http://search.cpan.org/~karasik/Array-Slice-0.03/Slice.pm |