我有一个 html 文件存储在磁盘上(文件是This)。我想删除图像的所有 html 标签。这是我到目前为止所尝试的。
#!/usr/bin/perl -w
use HTML::TagFilter;
my $tf = new HTML::TagFilter;
open READ, "D:\\Scripts\\file.html" or die "Couldn't open file: $!";
$string1 = join("", <READ>);
close READ;
my $self = HTML::TagFilter->new(deny => {img => {'all'}});
open (MYFILE, '>D:\\Scripts\\remove.html');
print MYFILE $tf->filter($string1);
close (MYFILE);
如果我只是运行这个程序,它会打印
Odd number of elements in anonymous hash at remove everything else.pl line 9.
Parsing of undecoded UTF-8 will give garbage when decoding entities at C:/Perl64
/site/lib/HTML/TagFilter.pm line 499.
该文件已存储,但没有删除图像标签(第 9 行是我应用过滤器的位置)。我在这里做错了什么。