use strict; package Our::Redirects; sub www_theirsite_com { my $url = shift; # and transform url here however } # allow for alt domain names *www_theirsite_co_uk = \&www_theirsite_com; package main; use URI; while ( <> ) { my $uri = URI->new($_) or die "Can't parse URI"; my $func = lc( $uri->host() ); $func =~ tr/.-/_/; if ( defined &{ "Our::Redirects::$func" } ) { &{ \&{ "Our::Redirects::$func" } }($_); } }