use strict; use warnings; use Data::Dumper; my @array = (); for my $i (0..1) { for ($i*5+1..$i*5+5) { push @{$array[$i]}, $_; # push an element at a time } } print Dumper(\@array); @array = (); # one-liner with map and slice. @array[0..1] = map { [ $_*5+1 .. $_*5+5 ] } 0..1; print Dumper(\@array);
In reply to Re: Arrays that points to another array
by Roger
in thread Arrays that points to another array
by TASdvlper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |