One more tip. If you want to control the timestamp format, I usually drop the subroutine as shown below. This will return a scalar in the format "20120928 08:35:12".
sub getLoggingTime { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); my $nice_timestamp = sprintf ( "%04d%02d%02d %02d:%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec); return $nice_timestamp; }
Then change your code to:
my $timestamp = getLoggingTime();
source share