Why use s/// when a match works better... ($url) = $url =~ m{^http://www\.(.*?)\.com} be sure to remember that this is not the same as $url = $url =~ m{^http://www\.(.*?)\.com} ..that one calls the match in scalar context (a true/false) instead of in list context (returns a list of the $DIGITs)