Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Using elements of a list in chunks - &List::MoreUtils::natatime

by Anonymous Monk
on Jul 07, 2012 at 15:02 UTC ( #980487=perlmeditation: print w/ replies, xml ) Need Help??

I was looking for a module that would give back an iterator and/or elements to work over a list in chunks. Wrote it once or twice in different places; forgot about it. Then needed it again few days ago. This time I put the work (closure based) in a local module. Nonetheless I tried to search CPAN.

Array::Iterator does not have seem to have the provision to specify chunk|step size; Parallel::Iterator seemed heavy and am not sure about &batch (even after reading pod). Searching CPAN some more, I finally found that &List::MoreUtils::natatime does what I am after.

Comment on Using elements of a list in chunks - &List::MoreUtils::natatime
Re: Using elements of a list in chunks - &List::MoreUtils::natatime
by tobyink (Abbot) on Jul 07, 2012 at 16:13 UTC
    Yes. Awful name, useful function.
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: Using elements of a list in chunks - &List::MoreUtils::natatime
by eyepopslikeamosquito (Canon) on Jul 08, 2012 at 06:44 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://980487]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2014-10-21 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (100 votes), past polls