#!/bin/perl -w use strict; my $server = "http://www.foo.com"; my $path = "/absolute/path/"; while( ) { s{<\s*a\s*href=(['"])(.*?)\1\s*>([^<]*)} { build_link( $2, $3) }seg; # hand out the updating to a subroutine print; } sub build_link # here we can play with the href attribute { my( $href, $text)= @_; if( $href=~ m{^(http|telnet|gopher|file|wais|ftp)://}) { return qq{$text}; } elsif( $href=~ m{^/}) { return qq{$text}; } else { return qq{$text}; } } __DATA__ absolute with no dns http://absolute.with/dns.html relative/without/dns.html relative2 without dns.html relative/without/dns.html toto