无论出于何种原因,我不得不尝试一些大的有序文件处理,我开始尝试使用以下方式使用文件哈希:
my %fo=();#File operations hash
foreach my $fn("file1","file2","file3","file4"){
open($fo{$fn}{"if"},"<","$fn") or die ("Error open input file $fn: $!");#Input file
$fo{$fn}{"v"} = <$fo{$fn}{"if"}>;#read one record
}
所以当打印 Dumper(\%fo) 我得到:
$VAR1 = {
'file1' => {
'v' => undef,
'if' => \*{'::$__ANONIO__'}
},
'file2' => {
'v' => 'GLOB(0x8f5f098)',
'if' => \*{'::$__ANONIO__'}
},
'file3' => {
'v' => undef,
'if' => \*{'::$__ANONIO__'}
},
'file4' => {
'v' => 'GLOB(0x8edf1e0)',
'if' => \*{'::$__ANONIO__'}
}
};
我的问题是,当“指针”是哈希时,如何正确读取文件?该文件正在正确打开并且文件不是空的,但我在 Dumper 输出中找不到这些行,并且我不确定如何/从 GLOB(哈希)中解释什么。
谢谢。