Tools to help track how the Perl script was run:
getppid returns the parent id of the process. You can then use ps or /proc/<pid> to get more information about the calling process.
$^X : the full path to the perl interpreter, which can give an idea of how Perl was launched from the shell
$0 , __FILE__ : the script name is called from the command line and the current file name. If they are consistent, then the current file contains a script that was called from the command line.
@ARGV : command line arguments passed to your script. With $^X , $0 and @ARGV you know exactly how the Perl interpreter was launched from the shell.
caller : stack trace information. If caller returns undef at the beginning of the script, then you are in the top frame of the stack and your script has been called from the shell. Otherwise, caller returns the package, file, and line where your script was called (using do or require ).
$^T : the time (in seconds since the "era") that the current Perl script is, so you know when the current Perl interpreter was launched from the shell. Use scalar localtime($^T) to see this value in a more friendly format.
source share