in reply to an ever-available file for opening

I can only think of two minor potential problems with $0.

Firstly, there are many circumstances where it can end up holding a relative path to the script, rather than an absolute one. If you then chdir, the relative path won't make sense. So don't do that.

Secondly, $0 is meaningless when perl is interpreting standard input. So don't do that either.

Other than that, I think you're golden. By definition the current process *must* have sufficient permission to read the script file, or it can't run it. So unless there's some bizarre suid situation I'm not considering, it should always be safe to open.

Replies are listed 'Best First'.
Re^2: an ever-available file for opening
by plobsing (Friar) on Jan 16, 2008 at 05:54 UTC
    There will be a small race condition if you assume your script file still exists.
    Some operating systems will let you delete scripts from disk while they run.
    example of a problem