简体   繁体   English

在perl中的array数组中插入元素

[英]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]. 这里的第三个元素是一个数组数组,我想插入一个数组[9,10]。

how can do this? 怎么办呢?

Use push and a dereference ( @{...} ): 使用push和解除引用( @{...} ):

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

Note that there is no "hash" involved. 请注意,不涉及“哈希”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM