[tpm] splitting filespecs
Fulko Hew
fulko.hew at gmail.com
Thu May 10 08:59:16 PDT 2012
I'm looking for a good library to split a filespec into directory
and filename components; so I can:
a) add a default dirspec if one wasn't provided
b) add a default filename if one wasn't provided
c) create the required directory path if it didn't already exist
So far I've tried
File::Basename and File::Spec
Unfortunately they both mis-behave?
File::Basename always provides a dirspec even if the original string didn't
have one
(so I can't tell if I need to insert my default one...)
and File::Spec (as far as I'm concerned) incorrectly splits '/.' into
the directory of '/.' with no file name. I would have expected the
directory to be '/' and the filename to be '.'.
Am I wrong?
Is there a better library?
[I suppose I could just take the filename from File::Spec and manually
extract everything in front of it from the original string as the directory
and simply _ignore_ what the module tells me.]
... and yes, I will eventually also need to parse DOS filespecs.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20120510/6ad24f50/attachment.html>
More information about the toronto-pm
mailing list