Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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?
[Corion]: choroboa: A good choice! ;)
[Corion]: I still somewhat wonder if it were worthwhile to replace init / systemd by make with a simple? Makefile listing the dependencies ...
[Discipulus]: i have a different opinion: automation is always worth: first i can use Perl (and this is good), then later you can reuse parts to automate others tasks. My $boss everytime say:'how much time you spend doing this?' So generally i present a perl solution
[Corion]: Discipulus: Yes, but the chart gives some limits on whether it's really worth spending time for saving your time. If you gain enjoyment, automating is still great, but it doesn't save time ;)
[Discipulus]: Corion are you would able to realize such thing? O_O
[Corion]: In the same vein I have a script that automates Firefox to enter some data into another system. It's not faster than the people using the script if they were to do it manually, but they prefer not having to check the data and not having typos when ...
[Corion]: ... entering the data

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2017-07-27 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (408 votes). Check out past polls.