How do I get the full path to a Perl script that is executing?

后端 未结 23 3019
情深已故
情深已故 2020-11-28 19:29

I have Perl script and need to determine the full path and filename of the script during execution. I discovered that depending on how you call the script $0 va

23条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 19:56

    On *nix, you likely have the "whereis" command, which searches your $PATH looking for a binary with a given name. If $0 doesn't contain the full path name, running whereis $scriptname and saving the result into a variable should tell you where the script is located.

提交回复
热议问题