Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Getting the absolute path of a script, without PWD

by perlancar (Hermit)
on Jul 15, 2021 at 12:02 UTC ( #11135025=note: print w/replies, xml ) Need Help??


in reply to Re: Getting the absolute path of a script, without PWD
in thread Getting the shell's version of working directory, without PWD's help

One reason is for logging path and the symlinked version is more meaningful and/or hides unwanted detail. For example I have a device /media/USER/1234-5678 mounted but I also keep /media/USER/MORE-MEANINGFUL-NAME symlinked to it and want to log the filenames inside the symlinked version. Okay not a great example as I should've just relabeled the removable volume in the first place, but that's the only example I can think of right now. There are other cases I've encountered previously.
  • Comment on Re^2: Getting the absolute path of a script, without PWD

Replies are listed 'Best First'.
Re^3: Getting the absolute path of a script, without PWD
by hippo (Bishop) on Jul 15, 2021 at 12:28 UTC

    Sure - there may be some cases where you might want the symlink name rather than the target. But that's not what you've asked. Your question says "... without PWD". Why impose this arbitrary restriction? If you want what $PWD gives, why not just use it?


    🦛

      Yes, that's just a curiosity. I'm using PWD right now.
Re^3: Getting the absolute path of a script, without PWD
by Tux (Canon) on Jul 15, 2021 at 14:48 UTC

    Find the symlinks and build a reverse hash lookup-table.


    Enjoy, Have FUN! H.Merijn
      This will result in a permutation of possible paths. How would you know which path is the correct one?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135025]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2023-12-02 05:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (13 votes). Check out past polls.

    Notices?