#! perl -slw use strict; use Data::Dumper; my %map = map{ split /=/, $_, 2 } split /\n/, do{ local $/; }; print Dumper \%map; while( <> ) { chomp; if( m[http://([^/]+)/(\W?)]i ) { next unless defined $map{ $1 }; substr( $_, $-[0], $+[0] - $-[0] ) = 'http://' . $map{ $1 } . ( length $2 ? $2 : "\n$2" ); } print; } __DATA__ www.theirsite.com=our.server1/theirsite/ www.dummy.com=our.server2/dummy/