如何打印在另一个文件中定义的哈希元素?
文件 1.pl:
#!/usr/bin/perl
use strict;
use warnings;
our %hash =
("Quarter" , 25,
"Dime" , 10,
"Nickel" , 5 );
文件2.pl:
#!/usr/bin/perl
use strict;
use warnings;
require "file1.pl"
foreach (sort keys %hash){
print "$hash{$_}\n";
}
输出:
Global symbol "%hash" requires explicit package name.
Global symbol "%hash" requires explicit package name.
请帮助