Bootstrap FreeKB - Perl (Scripting) - scriptname $0
Perl (Scripting) - scriptname $0

Updated:   |  Perl (Scripting) articles

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 Here is how you would show that is the name of the script.

use strict;
use warnings;
print "Script name = $0 \n";


Or, more commonly, scriptname is stored in a constant variable.

use strict;
use warnings;
my $scriptname = $0;
print "Script name = $scriptname \n";


Which should return the following.

Script name =


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

Please enter a6175d in the box below so that we can be sure you are a human.