我在磁盘上存储了一个 html 文件( 文件是 < a href=> http:// home. howstuffworks. com/ home- improprovement/ building/ projects/ return- on- investment- from- remodel2.htm > rel= "nofollow" > this a>) 。 我想删除图像的所有 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行是我应用过滤器的地方) 。 我在这里做错了什么 。