This depends on the originating OS of the given $path_and_file. If I remember correctly, then the path
given through a CGI file upload may be in MSDOS format
(with backslashes). Processing this filename with
basename or splitpath on a Unix system would give
wrong results.
So if you know the path is a MSDOS path, you should use
File::Spec::Win32->splitpath instead of File::Spec->splitpath.
See here:
use File::Spec;
warn ((File::Spec->splitpath("c:\\foo\\bar\\basename"))[-1]);
would return c:\foo\bar\basename at ... on a Unix system, while
use File::Spec::Win32;
warn ((File::Spec::Win32->splitpath("c:\\foo\\bar\\basename"))[-1]);
would return basename at ... on all systems.
|