Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Rosetta code: Split an array into chunks

by muba (Priest)
on Sep 26, 2010 at 04:34 UTC ( #862049=note: print w/replies, xml ) Need Help??


in reply to Rosetta code: Split an array into chunks

muba@localhost ~ $ cat rosetta sub chunky { my ($n, @l) = @_; my @f = ( ( (' ')x ($n-1)), "\n"); my $str = ''; $str .= shift(@l) . do {push(@f, shift @f); @l ? $f[-1] : ""} whil +e @l; return "$str\n"; } print chunky 3, qw(a bb c d e f g h); muba@localhost ~ $ perl rosetta a bb c d e f g h muba@localhost ~ $

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://862049]
help
Chatterbox?
[ambrus]: My boss wants to generate output data that is impossible to compute from the inputs we have. And I'm trying to convince him that he shouldn't do that.

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2017-12-12 12:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (332 votes). Check out past polls.

    Notices?