in reply to adding hostnames to absolute links

Seems like a lot of extra work:
$doctext =~ s/(a href=")([^"]+)/$1 . link_check($2)/eg; sub link_check { my $link = shift; # $hostname is a global or block lexical return $link if ($link =~ /^http://$hostname/); $link =~ s!(http://[^/]+)?!$hostname!; return $link; }
Disclaimer: this is untested.

Update: Changed the second $1 on the RHS to $2, as originally intended.