解除引用嵌套哈希perl

时间:2015-10-26 18:10:42

标签: perl perl-hash

如果我声明这样的哈希:

my %n = (a => {1 => "1a",2 => "2a"},"b" => {1 => "1b",2 => "2b"});

如何访问以下数据:n - > a - > 1?

我试过

print "$n{a{1}}";

print "$n{a ->{ 1}}";

这两个人没有工作

1 个答案:

答案 0 :(得分:1)

请参阅perldsc

use warnings;
use strict;

my %n = (a => {1 => "1a",2 => "2a"},"b" => {1 => "1b",2 => "2b"});
print "$n{a}{1}\n";

__END__

1a