recognizing and removing an entity from a text node with HTML::Tree
am 03.12.2005 00:38:59 von metaperl------=_Part_5898_27168290.1133566739038
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
When I set $target in the following program to an obvious string, I can
remove it from any text segment with ease. What I am confused about it why =
I
cannot set $target to and then remove it just as easily.
use strict;
use warnings;
use HTML::TreeBuilder;
my $html =3D '
Blah
hithere
Blah
';my $element_root =3D HTML::TreeBuilder->new_from_content($html);
$element_root->objectify_text;
$element_root->dump;
print "\n";
my $target;
$target =3D ' ';
$target =3D 'hi';
my @text =3D $element_root->look_down('_tag' =3D> '~text');
for my $text_node (@text) {
my $tmp =3D $text_node->attr('text');
warn $tmp;
if ($tmp =3D~ m!$target!) {
warn 'here';
$tmp =3D~ s!$target!!g;
$text_node->attr(text =3D> $tmp);
}
}
print "\n";
$element_root->dump;
------=_Part_5898_27168290.1133566739038--