in reply to Splitting an url in its components

Here's a solution using "split":

use strict; my @urls = qw( http://foo.com/downloads/pkg-5.6.tar.gz http://bar.com/list/file-5.6-win32.zip ); for my $url (@urls) { my @stuff = split(/\//, $url); # split on '/' my $file = pop @stuff; # take item off the 'right' side print "file = $file\n"; my @stuff2 = split(/\./, $file); # split on '.' my $file2 = shift @stuff2; # take item of 'left' side print "file2 = $file2\n"; }