I'm wondering if it's possible to get/recreate the version of working directory that is the same as the bash version given via PWD environment variable, without using the PWD (I'm thinking no). With Cwd's getcwd() and friends, symbolic links are resolved. I want absolute path of working directory but with symbolic links not resolved like the version bash gives me in PWD, which might have some symlinks in its elements.

Illustration:

% pwd /home/foo % mkdir dir1 % ln -s dir1 sym1 % cd sym1 % echo $PWD /home/foo/sym1 % perl -MCwd=getcwd -E'say getcwd' /home/foo/dir1

UPDATE: Correct the title and wording of what I am asking.


In reply to Getting the shell's version of working directory, without PWD's help by perlancar

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