|
|
Question : get file name from URL string
|
|
In Perl, I want to strip out the web location from a string and only leave the file name of the document.
let's say the string is:
my $myURL = $ENV{HTTP_REFERER};
$myURL now contains the string "http://www.mydomain.com/dir1/dir2/dir3/page.html";
I want to extract the filename from the string and be left with:
my $myFile = "page.html";
What is the code to do this? I'm still trying to understand the string functions of Perl, so a description of the solution would also be very helpful. Thanks in advance!
|
Answer : get file name from URL string
|
|
$myURL =~ s/.*\///g;
This will remove the data till the last '/' in the string variable
|
|
|
|