Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have filenames like:
I want to basically remove the path for each variable.$file1 = C:\test\abc.txt $file2 = C:\test\file2.txt $file3 = P:\cool\file3.txt
Hence,
etc...$file1 = abc.txt $file2 = files2.txt
Please suggest how to grab everything till the last "\" and substitute it for nothing.
I was thinking this:
Please advice.$file =~ s/.*\\?//
Updated Steve_p - added code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: substituting file names
by Transient (Hermit) on May 06, 2005 at 20:40 UTC | |
by dwhitney (Beadle) on May 06, 2005 at 21:58 UTC | |
|
Re: substituting file names
by gopalr (Priest) on May 07, 2005 at 09:16 UTC | |
|
Re: substituting file names
by TedPride (Priest) on May 06, 2005 at 22:46 UTC | |
|
Re: substituting file names
by perlsen (Chaplain) on May 07, 2005 at 09:11 UTC |