Reputation: 560
I have created a simple multi-dimensional array:
my @arraytest = ([1, 2, 3],[4, 5, 6],[7, 8, 9]);
print "Array - @$_\n" for @arraytest;
Output:
Array - 1 2 3
Array - 4 5 6
Array - 7 8 9
How do I push "10, 11, 12" to the next element in this array?
Upvotes: 2
Views: 1753
Reputation: 54323
You need to create an array reference, and push that as the next element. The easiest way is to make an anonymous array ref.
push @arraytest, [10, 11, 12];
Your output now looks like this:
Array - 1 2 3
Array - 4 5 6
Array - 7 8 9
Array - 10 11 12
The important part is that your @arraytest
is an actual array (not a reference), so you can just operate on it directly with push
, pop
and so on.
See perllol for more details.
Upvotes: 9