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.