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

Re: Arrays manipulation

by kabel (Chaplain)
on May 01, 2003 at 07:59 UTC ( #254580=note: print w/ replies, xml ) Need Help??


in reply to Arrays manipulation

instead of processing the elements of the array one after each other, i create a list out of the elements. then a mod-3 counter puts them in the appropriate slot - that is the (IMO) cool part distinguishing the solution from the one leriksen gave.

use strict; use Data::Dumper; my @array = ('nfs,7,rw', 'afp,12,rro', 'cifs,32,ro', 'dns,5,rw', ); my @splitted_up = (); my $cnt = 0; push @{ $splitted_up[($cnt ++) % 3] }, $_ foreach (split (/,/, join (",",@array))); print (Dumper \@splitted_up);
generated output is the same.


Comment on Re: Arrays manipulation
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2015-07-05 18:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls