I just converted a project that was building file paths 'by hand' with join '/', @blah and similar methodology to use File::Spec so that it would produce nice cross-platform behavior. However, I got bit by the quirk that the Unix version of canonpath does not behaving identically to that for other OS's. Specifically, it does not collapse somedir/../ segments unless they are at the beginning of the file path. So it is not 100% cross-platform (!)

The reason for this behavior is outlined in Re: Cleaning up a path.

I'm sure this is rarely an issue, but in my case I really need to have all the parent shortcut's removed. I'm wondering if there is reason why this functionality can't be provided in some fashion perhaps by explicitly checking for symbolic links in the path? Is it just the case that no one felt the need for this to work the same in Unix and other OS's or is there some technical reason why this is an untenable undertaking?

Just thinking off the top of my head I can think of a number of approaches that might be possible

Is there some reason why at least one of these is a good idea?

--DrWhy

"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."


In reply to Making File::Spec cross platform by DrWhy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.