现在我的 file1 包含哈希的哈希值,如下所示:
package file1;
our %hash = (
'articles' => {
'vim' => '20 awesome articles posted',
'awk' => '9 awesome articles posted',
'sed' => '10 awesome articles posted'
},
'ebooks' => {
'linux 101' => 'Practical Examples to Build a Strong Foundation in Linux',
'nagios core' => 'Monitor Everything, Be Proactive, and Sleep Well'
}
);
我的 file2.pl 包含
#!/usr/bin/perl
use strict;
use warnings;
require 'file1';
my $key;
my $key1;
for $key (keys %file1::hash){
print "$key\n";
for $key1 (keys %{$file1::hash{$key1}}){
print "$key1\n";
}
}
现在我的问题是,我得到一个错误
“在 file2.pl 的哈希元素中使用未初始化的值”
当我尝试像这样访问哈希时:
for $key1 (keys %{$file1::hash{$key1}})
请帮忙。