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
In reply to Re: Re: Getting the filename from full path name ?
by demerphq
in thread Getting the filename from full path name ?
by peterr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |