The $0 variable can be used to get the name of the Perl script being invoked. For example, let's say you have a Perl script named foo.pl. Here is how you would show that foo.pl is the name of the script.
#!/usr/bin/perl use strict; use warnings; print "Script name = $0 \n";
Or, more commonly, scriptname is stored in a constant variable.
#!/usr/bin/perl use strict; use warnings; my $scriptname = $0; print "Script name = $scriptname \n";
Which should return the following.
Script name = foo.pl