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; }
In reply to Re: how to seperate array after a certain number of elements?
by hangon
in thread how to seperate array after a certain number of elements?
by adrive
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |