in reply to A better way? Extracting filename from url
i use these with local harddrive filenames, but they should work pretty much the same for url's
method 1:
$file = substr $url, rindex($url, '/') + 1; #path contains full url
method 2:
$url =~ s/^.*\///; #just use the url to get the filename with a regex
method 3:
($file) = $url =~ m!([^/]+)$!; #another regex way
method 1:
$file = substr $url, rindex($url, '/') + 1; #path contains full url
method 2:
$url =~ s/^.*\///; #just use the url to get the filename with a regex
method 3:
($file) = $url =~ m!([^/]+)$!; #another regex way
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: A better way? Extracting filename from url
by moodster (Hermit) on Jan 14, 2002 at 17:01 UTC | |
by Gerard (Pilgrim) on Jan 15, 2002 at 02:23 UTC |
In Section
Seekers of Perl Wisdom