我想将一些文件的内容保存到一个新文件中,我执行以下操作:
use strict;
use warnings;
use HTML::TreeBuilder::XPath;
my ($dir) = @ARGV;
my @files = glob "details/*";
my $filename = 'target.txt';
for my $file (@files) {
my $tree = HTML::TreeBuilder::XPath->new_from_file($file);
my @opacity = $tree->findnodes_as_strings('//div[@class="opacity description"]');
open my $fh, '>>', $filename;
print $fh for @opacity;
}
不幸的是,它不起作用。我不明白为什么?