user1939168
user1939168

Reputation: 557

Inserting element in an array of array in perl

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?

Upvotes: 1

Views: 298

Answers (1)

choroba
choroba

Reputation: 241758

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

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

Note that there is no "hash" involved.

Upvotes: 2

Related Questions