Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays Perl将数组分配给哈希引用_Arrays_Perl_Hash - Fatal编程技术网

Arrays Perl将数组分配给哈希引用

Arrays Perl将数组分配给哈希引用,arrays,perl,hash,Arrays,Perl,Hash,因此,如果我第一次运行这个脚本,它会工作,但是当我尝试向数组添加另一个值,然后将数组分配回哈希引用时,它会将数组的值(0x9bd8254)作为数组中的值 有问题的三行 @addedvalue = @{$state{$ustate}}{largest_city} ; push @addedvalue, $city; $state{$ustate}{largest_city} = \@addedvalue; 我想我在最后一行做错事了。当我在打印最后一行之前打印出数组时,它看起来很好。但我无

因此,如果我第一次运行这个脚本,它会工作,但是当我尝试向数组添加另一个值,然后将数组分配回哈希引用时,它会将数组的值(0x9bd8254)作为数组中的值

有问题的三行

@addedvalue =  @{$state{$ustate}}{largest_city}  ;
push @addedvalue, $city;
$state{$ustate}{largest_city} =  \@addedvalue; 
我想我在最后一行做错事了。当我在打印最后一行之前打印出数组时,它看起来很好。但我无法确定我做错了什么。 任何帮助都会很好


谢谢

哈希只能包含标量,因此您使用了对数组(而不是数组)的引用作为哈希元素的值

$state{$ustate}{largest_city} = \@addedvalue; 
print("@{ $state{$ustate}{largest_city} }\n");
但在打印时,打印的是哈希元素的值,而不是哈希元素的值所引用的数组元素

$state{$ustate}{largest_city} = \@addedvalue; 
print("@{ $state{$ustate}{largest_city} }\n");

但看起来奇怪的是,最大的城市需要一个数组。以下内容更有意义

$state{$ustate}{largest_city} = $city; 
print("$state{$ustate}{largest_city}\n");

哈希只能包含标量,因此您使用了对数组(而不是数组)的引用作为哈希元素的值

$state{$ustate}{largest_city} = \@addedvalue; 
print("@{ $state{$ustate}{largest_city} }\n");
但在打印时,打印的是哈希元素的值,而不是哈希元素的值所引用的数组元素

$state{$ustate}{largest_city} = \@addedvalue; 
print("@{ $state{$ustate}{largest_city} }\n");

但看起来奇怪的是,最大的城市需要一个数组。以下内容更有意义

$state{$ustate}{largest_city} = $city; 
print("$state{$ustate}{largest_city}\n");

哈希只能包含标量,因此您使用了对数组(而不是数组)的引用作为哈希元素的值

$state{$ustate}{largest_city} = \@addedvalue; 
print("@{ $state{$ustate}{largest_city} }\n");
但在打印时,打印的是哈希元素的值,而不是哈希元素的值所引用的数组元素

$state{$ustate}{largest_city} = \@addedvalue; 
print("@{ $state{$ustate}{largest_city} }\n");

但看起来奇怪的是,最大的城市需要一个数组。以下内容更有意义

$state{$ustate}{largest_city} = $city; 
print("$state{$ustate}{largest_city}\n");

哈希只能包含标量,因此您使用了对数组(而不是数组)的引用作为哈希元素的值

$state{$ustate}{largest_city} = \@addedvalue; 
print("@{ $state{$ustate}{largest_city} }\n");
但在打印时,打印的是哈希元素的值,而不是哈希元素的值所引用的数组元素

$state{$ustate}{largest_city} = \@addedvalue; 
print("@{ $state{$ustate}{largest_city} }\n");

但看起来奇怪的是,最大的城市需要一个数组。以下内容更有意义

$state{$ustate}{largest_city} = $city; 
print("$state{$ustate}{largest_city}\n");

使用Perl调试器检查每一步的值。发布调试会话的副本。使用Perl调试器检查每个步骤的值。发布调试会话的副本。使用Perl调试器检查每个步骤的值。发布调试会话的副本。使用Perl调试器检查每个步骤的值。发布调试会话的副本。