小编Hel*_*rah的帖子

在 perl 中管理散列数组中的文件句柄

我有一个哈希数组,我按以下方式填写:

# Array of hashes, for the files, regexps and more.
my @AoH;
push @AoH, { root => "msgFile", file => my $msgFile, filefh => my $msgFilefh, cleanregexp => s/.+Msg:/Msg:/g, storeregexp => '^Msg:' };
Run Code Online (Sandbox Code Playgroud)

这是其中一个条目,我有更多这样的。并且一直使用散列的每个键值对来创建文件、清理文本文件中的行等等。问题是,我通过以下方式创建了文件:

# Creating folder for containing module files.
my $modulesdir = "$dir/temp";

# Creating and opening files by module.
for my $i ( 0 .. $#AoH )
{
    # Generating the name of the file, and storing it in hash.
    $AoH[$i]{file} = "$modulesdir/$AoH[$i]{root}.csv";
    # Creating and …
Run Code Online (Sandbox Code Playgroud)

perl filehandle

0
推荐指数
1
解决办法
58
查看次数

标签 统计

filehandle ×1

perl ×1