use File::Basename; my $url = "http://google.com/folder/1234.html"; print basename($url, '.html');