引用混乱虽然看着 http://perl.plover.com/FAQs/references.htmlPerl中使用散列值是阵列
从下面,我真不明白 @{ $table{$state} }
它解释说,这是哈希表,其中的关键是$state
和值数组..所以这基本上是 正常%table
和其值将数组..这是正确的方式来看待这个?
难道还有%{ $table{$state} }
这样的事吗?我甚至不知道这是否意味着什么。
1 while (<>) {
2 chomp;
3 my ($city, $state) = split /, /;
4 push @{$table{$state}}, $city;
5 }
6
7 foreach $state (sort keys %table) {
8 print "$state: ";
9 my @cities = @{$table{$state}};
10 print join ', ', sort @cities;
11 print ".\n";
12 }
请检查['HoA'](http://perldoc.perl.org/perldsc.html#HASHES-OF-ARRAYS)和['HoH'](http://perldoc.perl.org/perldsc。 html#HASHES-OF-HASHES) –