Today I noticed a surprising behaviour of the Perl Cwd module with directories that are symbolic links, as demonstrated by the Unix shell commands below:

# echo $PWD /home/devel/devut/build64 # ls -l $PWD ... /home/devel/devut/build64 -> /opt/oflow/librarian/build64 # pwd /home/devel/devut/build64 # pwd -P /opt/oflow/librarian/build64 # perl -l -MCwd -e 'print Cwd::getcwd()' /opt/oflow/librarian/build64 # perl -l -MCwd -e 'print Cwd::cwd()' /opt/oflow/librarian/build64
Since the introduction of symbolic links has broken a number of my automated tests, I'm eager to fix them as simply as possible. Though I could replace the Cwd::cwd() calls with `pwd` (for Unix only), I'd prefer a more portable solution. Ideal would be to somehow tell the Perl Cwd module to behave like the Unix pwd command. Browsing the Cwd docs, however, revealed no obvious way to achieve that. Note that the Unix pwd command provides a -P option to control this behaviour.

I googled for this problem, but found precious little:

Note that these are not especially useful links.


In reply to Surprising behavior of Cwd module on Unix with symlinks by Anonymous Monk

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.