#!/usr/bin/perl --
use strict;
use warnings;
use HTML::TreeBuilder;
my $html = '<html><body>
<a href="/cgi-programming-with-perl.zip">cgi-programming-with-perl.zip
+</a>
<a href="cgi-programming-with-perl.zip">cgi-programming-with-perl.zip<
+/a>
</body></html>';
{
my $tree = HTML::TreeBuilder->new();
$tree->ignore_ignorable_whitespace(0);
$tree->no_space_compacting(1);
$tree->parse( $html )->eof;
$tree->look_down( qw' _tag a href ', qr!^/! ,
sub {
$_[0]->push_content(
HTML::Element->new('b')->push_content(
$_[0]->detach_content
),
);
return;
},
);
print $tree->as_HTML('<>&',' ',{}), "\n";
}
__END__
<html>
<head>
</head>
<body>
<a href="/cgi-programming-with-perl.zip"><b>cgi-programming-with-perl.
+zip</b></a>
<a href="cgi-programming-with-perl.zip">cgi-programming-with-perl.zip<
+/a>
</body>
</html>