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

Re: how to seperate array after a certain number of elements?

by hangon (Deacon)
on Sep 20, 2007 at 04:13 UTC ( [id://640041]=note: print w/replies, xml ) Need Help??


in reply to how to seperate array after a certain number of elements?

Here's another nondestructive method using array slices.

use strict; use warnings; my @myArray = (1..100); my @myMainArray = (); my $i = 0; while ($i < scalar @myArray){ push (@myMainArray, [@myArray[$i .. $i+4]]); $i += 5; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-29 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found