http://www.perlmonks.org?node_id=203133


in reply to regex a url

An alternative directly using a regexp is to use the URI::URL (or even just the URI) module. This module is especially handy when when dealing with and manipulating URLs.
use URI::URL; my $url = URI::URL->new('http://www.merchandisemarket.net/shop/s_image +s/aaa_small.gif ') my ($filename) = ($url->path_segments)[-1];