我在 Perl 中遇到了一些有趣的行为,希望能有所启发。如您所见,我创建了一个名为的数组,该数组@tuple
具有两个数组引用。当我将它分配给一个键并提取它时,我只得到与引用相对的第一个数组 VALUE。谁能告诉我为什么会这样?
my @VMstoreName = ($storeName[$i]);
my @VMdiskCap = ($diskCap[$i]);
print "VMstoreName : ". join(' ', @VMstoreName) . "\n";
print "VMdiskCap : ". join(' ', @VMdiskCap) . "\n";
# Initializing our key
my @tuple = (\@VMstoreName, \@VMdiskCap);
print "After tuple " . join(' ', @tuple) . "\n";
@virtualMachines{$vmNames[$i]} = @tuple;
my @DEBUG = @{$virtualMachines{$vmNames[$i]}};
print "After first map : " . join(' ', @DEBUG) . "\n";
print "WHAT??? $DEBUG[0] $DEBUG[1]!!!\n";
这是输出,我希望 After first map 读取完全像 After tuple
VMstoreName : 172.16.1.3:/export/Paul/test-0
VMdiskCap : 1
After tuple ARRAY(0x2c4ccf0) ARRAY(0x2c4cd38)
After first map 172.16.1.3:/export/Paul/test-0
WHAT??? 172.16.1.3:/export/Paul/test-0 !!!