【发布时间】:2021-01-15 00:47:30
【问题描述】:
当我想将输入文件分配给数组时,我收到了这个错误。
while (<>) {
my @tmp = split;
push my @arr,[@tmp];
print "@arr\n";
}
output: ARRAY(0x7f0b00)
ARRAY(0x7fb2f0)
如果我将[ 更改为(,那么我将获得所需的输出。
while (<>) {
my @tmp = split;
push my @arr,(@tmp);
print "@arr\n";
output: hello, testing the perl
check the arrays.
(@tmp) 和 [@tmp] 之间的区别是什么?
【问题讨论】:
标签: arrays perl multidimensional-array reference