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?

1 Answer 1

2

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

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

Note that there is no "hash" involved.

Sign up to request clarification or add additional context in comments.

1 Comment

As of 5.14 the dereference @{ } is no longer necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.