in reply to I want to be a Perl Jedi
Where the backticks quietly go off and spawn another process to get the date for you. Very slow in comparison to the Perl way: localtime(time); Seeing that you just want the day/month/year, you can do this by saying:chomp($DATE=`date +%d%b%y`);
As usuall, this can be made more tight and efficient, I'm not playing Perl Golf, just showing you don't need to make a shell call to get the date. For more info read perldoc:localtime.my @date = (localtime(time))[3..5]; # Get the date. (18, 6, 10 +0) ++$date[1] and $date[2] += 1900; # Make it reader friendly for( @date[0..1] ){ $_ = "0$_" if 10 > $_ } # Add 0 prefixes as needed +. my $DATE = join '', @date; # now 18072000
|
|---|