);
exit;
sub processHTML {
my $tree = HTML::TreeBuilder->new_from_content($_[0]);
$tree->elementify();
my @body = $tree->look_down("_tag", "body");
for my $body (@body) {
$body->objectify_text();
my @perl_parts = $body->look_down("_tag", "~text",
sub {$_[0]->attr('text') =~ /perl/i}
);
for my $perl_text ( @perl_parts ) {
my @items = split(/(perl)/i, $perl_text->attr('text'));
$_ = (/perl/i ? b($_) : $_) for @items ;
$perl_text->replace_with(@items)->delete();
}
$body->deobjectify_text();
}
my $return = $tree->as_HTML;
$tree->delete;
$return;
}
__END__
This title contains Perl but does not get changed.
This is some text containing the term 'perl'.
- Unix
- Perl
- Linux
Notice how the term perl in the following link doesn't change, but the text does.
Perlmonks.org