Sunday, February 15, 2015

How do you set name of logfile to that of script basename?

use Time::Piece;

# Get the base name of the script
( my $me = $0 ) =~ s{.*(\\|/)}{};

my $today = localtime->strftime('%d%m%Y');

#Set name of log file to that of script name
(my $logfile = $me ) =~ s/\.pl/\_$today\.log/ig;