Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Rosetta code: Split an array into chunks

by GrandFather (Sage)
on Sep 25, 2010 at 09:54 UTC ( #861940=note: print w/replies, xml ) Need Help??


in reply to Rosetta code: Split an array into chunks

I'd have thought the idiomatic Perl solution would splice:

sub chunky { my ($n, @strs) = @_; my $str = ''; $str .= join (' ', splice @strs, 0, $n) . "\n" while @strs; return length $str ? $str : "\n"; }
True laziness is hard work

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://861940]
help
Chatterbox?
[hippo]: Sounds fun. Good luck with it all.
[stevieb]: Thank you. I've got nearly all of it polished up, and have learned a boat load of things through the process

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (12)
As of 2017-01-20 17:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (176 votes). Check out past polls.