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

I thought I sent this a long time ago, but I dont see it in my mail
reader, so i am sending again:
-------------------------------

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

my $element_root = HTML::TreeBuilder->new_from_content($html);

$element_root->objectify_text;

$element_root->dump;
print "\n";

my $target;
$target = ' '; # cant be removed.. even with below commented out
$target = 'hi'; # can be removed...

my [at] text = $element_root->look_down('_tag' => '~text');
for my $text_node ( [at] text) {
my $tmp = $text_node->attr('text');
warn $tmp;
if ($tmp =~ m!$target!) {
warn 'here';
$tmp =~ s!$target!!g;
$text_node->attr(text => $tmp);
}
}

print "\n";
$element_root->dump;
tbrannon [ Mo, 05 Dezember 2005 23:30 ] [ ID #1090900 ]
Perl » perl.libwww » recognizing and removing an entity from a text node with HTML::Tree

Vorheriges Thema: LWP 5.803 build failure on Mac OS X 10.3.9
Nächstes Thema: Re: GSS_C_MUTUAL_FLAG;