What about List::MoreUtil's natatime() for N at a time function?
https://metacpan.org/module/List::MoreUtils
You can do stuff like:
my $it = natatime 3, @x;
while ( my ( $one, $two, $three ) = $it->() ) {
...
}
It's also lazy.
You can also use splice:
while ( my ( $one, $two ) = splice @x, 0, 2 ) {
say "$one, $two, Freddy's coming for you!";
}
On Wed, May 1, 2013 at 2:34 PM, Shlomi Fish <[email protected]> wrote:
> Hi Chanan,
>
> On Wed, 1 May 2013 11:23:14 +0300
> Chanan Berler <[email protected]> wrote:
>
> > Hi Shlomi,
> >
> > Never my intention of using un-friendly variables names as $a and $b
> > same as I am familiar with them used in sorting - mine was just an
> example
> > of something i am in need :)
> >
>
> I find it hard to understand your non-grammatical English, but I presume
> you
> want to imply that you don't use short-named variables such as "$a" and
> "$b" in
> production. What I wanted to say is that you should never use them except
> with
> conjunction with sort and friends (like those higher-order routines from
> List::Util or List::MoreUtils).
>
> That's because lexicalising them will cause the original $a and $b to
> become
> inaccessible. So don't do that because this will encourage bad practises
> and
> people sometimes learn from code like that, which they find in web
> searches.
>
> So please - NEVER LEXICALISE $a AND $b. Comprendre?!!
>
> Regards,
>
> Shlomi Fish
>
> --
> -----------------------------------------------------------------
> Shlomi Fish http://www.shlomifish.org/
> Apple Inc. is Evil - http://www.shlomifish.org/open-source/anti/apple/
>
> sed and awk make me sad and awkward.
>
> Please reply to list if it's a mailing list post - http://shlom.in/reply .
> _______________________________________________
> Perl mailing list
> [email protected]
> http://mail.perl.org.il/mailman/listinfo/perl
>
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl