Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2019-08-17 21:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (134 votes). Check out past polls.

    Notices?