laziness, impatience, and hubris | |
PerlMonks |
Re: A better way? Extracting filename from urlby Parham (Friar) |
on Jan 14, 2002 at 16:28 UTC ( [id://138556]=note: print w/replies, xml ) | Need Help?? |
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
In Section
Seekers of Perl Wisdom
|
|