recognizing and removing an entity from a text node with HTML::Tree

------=_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 '<h1>Blah</h1> hithere <p> <br>
<h2>Blah</h2>';

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 [at] text =3D $element_root->look_down('_tag' =3D> '~text');
for my $text_node ( [at] 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--
metaperl [ Sa, 03 Dezember 2005 00:38 ] [ ID #1085270 ]
Perl » perl.libwww » recognizing and removing an entity from a text node with HTML::Tree

Vorheriges Thema: Re: GSS_C_MUTUAL_FLAG;
Nächstes Thema: LWP won't install