我刚刚拿起 Perl。我对访问哈希值有点困惑。下面是我试图访问散列中散列值的代码。由于我使用简单的文本编辑器进行编码,因此我无法弄清楚可能是什么问题。请帮忙
my %box = (
Milk => {
A => 5,
B => 10,
C => 20,
},
Chocolate => {
AB => 10,
BC => 25,
CD => 40,
},
);
foreach my $box_key(keys %box) {
foreach my $inside_key (keys %box{box_key})
print "$box_key"."_$inside_key""is for rupees $box{box_key}{inside_key}";
}