The main wheels I would suggest would be
HTML::Parser or any of several others in the
HTML:: tree, and
URI.
use URI;
use HTML::Parser;
my $parse = new HTML::Parser( default_h => [ sub {print shift}, 'text'
+ ],
start_h => [
sub {
my ($tag, $attr, $origtext) = @_;
if (($tag eq 'img') and ($attr->{src} =~ m#^(?:http://)?myserver\.
+#)) {
$attr->{img} = URI->new($attr->{img})->abs('http://myserver.com'
+);
print "<$tag " . join (' ', map {$_.'="' . $attr->{$_} . '"'} ke
+ys %$attr) . '>';
}
else {
print $origtext;
}
}, "tagname, attr, text"]
);
$parse->parse(join('',<>));
However this code is untested and may well need some work.
It currently would take input on STDIN and produce results
on STDOUT.