[tpm] splitting filespecs

Fulko Hew fulko.hew at gmail.com
Thu May 10 10:57:22 PDT 2012


On Thu, May 10, 2012 at 1:30 PM, <rob at cryptic.org> wrote:

> Further to that, "." actually is a special-case directory, similar to
> "..". Like a double period is "parent directory", a single period is
> "current directory". It's like this on both Unix and Windows (and
> presumably Mac).


Actually its both a special case filename and a directory.
My trouble is that as far as File::Spec is concerned '.' and '..' are
returned as the filename
... which is technically correct, BUT if thats all that was provided,
it really means 'this' or 'the parent' directory [not a filename]

As a result, I'd think the directory wasn't provided and substitute my own,
and use the
filename provided and end up with "/defdir/."
... which would be _completely_ wrong.

If someone gave me '.' as their 'target'  you'd want to interpret that as
"they want it to be in the 'default' file in _this current_ directory" ie.
./deffile


So in either case... these libraries still don't do it correctly (for my
needs)

I've ended up using a combo of special case tests for '.' and '..'
[meaning this (or parent directory) with no filename provided];
otherwise use File::Basename to extract the filename and
extract any stuff in front of the filename as the directory path
   (and ignore what File::Basename provides)
and then finally apply my default path (if the prefix/dirpath was empty)
and default filename (if filename was empty)
and then splice them back together again using File::Spec::catfile()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20120510/9b0a63a8/attachment-0001.html>


More information about the toronto-pm mailing list