1

Suppose i have a hash as below:

my @A=( 1,2,[[ 1,2 ],[ 3,4,5 ]], [ 6,7,8 ]);

How do i insert an array in the third element of the array above? Third element here is an array of arrays and i want to insert an array [9,10].

how can do this?

user1939168
  • 547
  • 5
  • 20

1 Answers1

2

Use push and a dereference (@{...}):

push @{ $A[2] }, [9, 10];

Note that there is no "hash" involved.

choroba
  • 231,213
  • 25
  • 204
  • 289
  • As of [5.14](http://perldoc.perl.org/perl5140delta.html#Syntactical-Enhancements) the dereference `@{ }` is no longer necessary. – Brad Gilbert Jun 09 '13 at 03:47