<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I've used File::Spec reliably for this, but it's right to claim that "." in "/." isn't a filename. It isn't really. I believe it is a special case used by UNIX to inform it that the thing specified is to be interpreted as a directory. So, for example, "/usr/x" could be a *file* named "x" (, but "/usr/x/." is specifically a directory. It's useful when it could be either and when it doesn't yet exist. This special case logic is built into File::Spec. </div><div><br></div><div>You should *always* be able to split things with File::Spec->splitpath/splitdir and rejoin with File::Spec->catpath/catdir, and I've always found it works well for both UNIX and for Windows. </div><div><br></div><div>All the best</div><div>Stuart</div><div><br></div><div><br></div><div><div>On 2012-05-10, at 11:59 AM, Fulko Hew wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><font style="font-family:courier new,monospace" face="courier new,monospace">I'm looking for a good library to split a filespec into directory<br>and filename components; so I can:<br><br>a) add a default dirspec  if one wasn't provided<br>

b) add a default filename if one wasn't provided<br>c) create the required directory path if it didn't already exist<br><br>So far I've tried <br><br>File::Basename and File::Spec<br><br>Unfortunately they both mis-behave?<br>

<br>File::Basename always provides a dirspec even if the original string didn't have one<br>(so I can't tell if I need to insert my default one...)<br><br>and</font><font style="font-family:courier new,monospace" face="courier new,monospace"> File::Spec (as far as I'm concerned) incorrectly splits '/.' into<br>

the directory of '/.' with no file name.  I would have expected the<br>directory to be '/' and the filename to be '.'.<br><br></font><span style="font-family:courier new,monospace">Am I wrong?</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">Is there a better library?</span><br><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">[I suppose I could just take the filename from File::Spec and manually<br>

extract everything</span><span style="font-family:courier new,monospace"> in front of it from the original string as the directory<br>and simply _ignore_ what the module tells me.]<br><br>... and yes, I will eventually also need to parse DOS filespecs.<br>

<br><br><br><br style="font-family:courier new,monospace"></span>
_______________________________________________<br>toronto-pm mailing list<br><a href="mailto:toronto-pm@pm.org">toronto-pm@pm.org</a><br>http://mail.pm.org/mailman/listinfo/toronto-pm<br></blockquote></div><br></body></html>