Disclaimer: this is untested.$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; }
Update: Changed the second $1 on the RHS to $2, as originally intended.
In reply to Re: adding hostnames to absolute links
by chromatic
in thread adding hostnames to absolute links
by zodiac
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |