in reply to Re: Getting the filename from full path name ?
in thread Getting the filename from full path name ?
Actually File::Basename is to say bluntly a turd. You are much better off using File::Spec and or the functional equivelents in File::Spec::Functions. File::Basename was effectvely deprecated when File::Spec was created (which it was to fix a whole bunch of know problems in the Basename, some outstanding to this day) but it never was marked as such or removed for hysterical porpoises. File::Spec is in the core and it should be used as a general rule for manipulating paths and directories and the like.
Anyway, the File::Spec::Functions way would be:
Or:use File::Spec::Functions qw(splitpath); my (undef,undef,$file)=splitpath($path);
use File::Spec; my ($vol,$path,$file)=File::Spec->splitpath($path);
Also IMO its not worth ignoring the $vol just becuase _your_ OS doesnt have such a concept. If you use File::Spec and assume there will be a volume then everything will work out regardless of where youtr code ends up.
First they ignore you, then they laugh at you, then they fight you, then you win.
-- Gandhi
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Getting the filename from full path name ?
by eserte (Deacon) on Apr 15, 2004 at 13:03 UTC | |
by demerphq (Chancellor) on Apr 15, 2004 at 13:20 UTC | |
by eserte (Deacon) on Apr 15, 2004 at 13:57 UTC | |
by demerphq (Chancellor) on Apr 15, 2004 at 15:46 UTC | |
by eserte (Deacon) on Apr 15, 2004 at 17:15 UTC | |
| |
by halley (Prior) on Apr 15, 2004 at 14:32 UTC | |
by demerphq (Chancellor) on Apr 15, 2004 at 16:06 UTC |