Snaps_Provolone has asked for the wisdom of the Perl Monks concerning the following question:
Result = "path1path2path3ile.ext" Note: The wierd character after 3 looks like a little circle on top of a cross in my command prompt window on NT.$path = "\path1\path2\path3\file.ext"; $path =~ s/(.*)\\(.*)/$2/gi; print "$path";
Result = "path1path2path3ile.ext" Note: Again there is the little funky character. Now for the kicker -use File::Spec; $path = "\path1\path2\path3\file.ext"; ($volume,$directories,$file) = File::Spec->splitpath($path); print "$file";
Result - "file.ext" Now thats what I am after hehe. I don't know why but for some reason the \ character seems to be causing me some troubles. I even tried using \\ and \x5C I don't know what else to try. I have read everything I can find on this suject, and have tried everything, but all seem to fail with this path.$path = "`path1`path2`path3`file.ext"; $path =~ s/(.*)`(.*)/$2/gi; print "$path";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extracting filename from a path string
by rob_au (Abbot) on Apr 20, 2002 at 13:33 UTC | |
|
Re: Extracting filename from a path string
by perlplexer (Hermit) on Apr 20, 2002 at 13:05 UTC | |
by Snaps_Provolone (Novice) on Apr 20, 2002 at 14:29 UTC | |
|
Re: Extracting filename from a path string
by dmmiller2k (Chaplain) on Apr 20, 2002 at 13:24 UTC | |
|
(smitz)Re: Extracting filename from a path string
by smitz (Chaplain) on Apr 20, 2002 at 13:08 UTC | |
|
Re: Extracting filename from a path string
by beebware (Pilgrim) on Apr 21, 2002 at 12:24 UTC |