$url = 'http://www.fubar.com/fileXXX.txt'; $url =~ m{^[\w\/\:\.]+\/([\w\.]+)$}; $file = $1;