Here is an example of getting the (base)name of the script being executed, from within the script.
chomp(my $SCRIPTNAME=`basename $0`);I usually use the script name in the usage/help text of the script.
It is interesting to note that the parentheses are required, because if you did this:
chomp $SCRIPTNAME=`basename $0`
It would be interpreted as:
(chomp $SCRIPTNAME) =`basename $0`
which is not what you want.
No comments:
Post a Comment