How to get the name of Perl script that is running
The name of the running program can be found in the
man perlvar for other special variables.
use File::Basename; my $name = basename($0);
getcwd() and friends don't give you the script's directory! They give you the working directory. If the script is in your PATH and you just call it by name, not by its full path, then
getcwd() won't do what you say. You want
dirname($0) (dirname also is in