in reply to Splitting an url in its components
What moritz said initially. URI is core and it's really simple and flexible once you get the hang of it. Solving problems with regexes in defined formats (URI, HTML, XML, whatever) is almost always a mistake.
use URI; my @uri = qw( http://foo.com/downloads/pkg-5.6.tar.gz http://bar.com/list/file-5.6-win32.zip ); for my $raw ( @uri ) { my $uri = URI->new($raw); printf("%s\n - %s\n - %s\n - %s\n\n", $uri, $uri->path, ( $uri->path_segments )[-1], $uri->host, ); } -- http://foo.com/downloads/pkg-5.6.tar.gz - /downloads/pkg-5.6.tar.gz - pkg-5.6.tar.gz - foo.com http://bar.com/list/file-5.6-win32.zip - /list/file-5.6-win32.zip - file-5.6-win32.zip - bar.com
|
|---|