所以,我有一个散列%HoHoA。 每个顶层散列键都有一个二级散列键作为值。 每个二级哈希都有数组作为值。Perl:散列中数组的大小,在另一个散列
在Perl的调试器,它看起来是这样的:
0 'Top_key_1'
1 HASH(0x...)
'Second_Key_1' => ARRAY(0x...)
0 'string 1'
1 'string 2'
'Second_Key_2' => ARRAY(0x...)
0 ARRAY(0x...)
0 'string 3'
1 'string 4'
2 'string 5'
1 ARRAY(0x...)
0 'string 6'
1 'string 7'
2 'Top_key_2'
我试图让每套房的两个数组的大小。另外,在上述 例如,Second_Key_2具有两个阵列中,第0之一是尺寸3.
my $count1 = $#{$HoHoA{$top_key}{$second_key}[0]}+1;
my $count2 = $#{$HoHoA{$top_key}{$second_key}[1]}+1;
和
my $count1 = @{$HoHoA{$group}{$suite}[0]};
my $count2 = @{$HoHoA{$group}{$suite}[1]};
我得到这样的错误消息: 不能使用字符串(“串3 “)作为ARRAY参考,同时使用”严格参考“
为什么我会收到该错误消息,而应该怎么做呢?
你读过[perldoc perldsc](http://perldoc.perl.org/perldsc.html)和[perldoc perllol](http://perldoc.perl.org/perllol.html)吗?那里详细剖析了一些非常相似的结构。 – Ether 2010-11-11 00:12:51
同样http://perlmonks.org/?node=References+quick+reference - 虽然你似乎明白了,但你的数据和你期望的数据略有不同。 – ysth 2010-11-11 03:01:10