in reply to Curious Symlink question

What you've written suggests that you want a file to know what symlinks there are to it. It does not. For the other direction — determining where a symlink points — use readlink.

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: Curious Symlink question
by patrickrock (Beadle) on May 02, 2005 at 22:59 UTC
    Roy,

    Yes, precisely. I wondered if there was a way for a file to know what symlink was originally.

    I thought maybe it got passed along or something.

    Sigh, I guessed not, but one can hope.
      If you're calling the program using the symlink, you can use __FILE__ (or, as the others have suggested, $0). That gives you the name of the program called, and it doesn't matter whether it's a symlink or a real file. If you're calling the program using the real file name, no. A file might have numerous symlinks to it, and it doesn't have any place to keep track of them.

      Caution: Contents may have been coded under pressure.
      You can, if you want the symlink used to start the Perl script currently being executed. It's in $0.