Thanks for your help. so far I was able to get the format for the filename with the current date and time. I am having a problem with the month though. The format is suppose to be: sample_yyyymmdd.hhmmss.1
what I keep getting is sample_2005425.153542.1 it should be sample_20050525.153542.1
the month is a single digit and from what i understand how perl works it goes for the array of 0-11 so i need to add 1 in order to get the current month but how do I make sure it includes the 0 for instance for may it would be 05
my ($sec,$min,$hours,$mday,$month,$year,$wday,$yday,$isdst)=localtime();
$nowyear=$year+1900;
Hmmm, Big issue here.
It's not just the month that will cause trouble, the day will too when it is in single figures (as will the time elements).
You might do better to use a sprintf so that you can control leading zero suppression.
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year+=1900; $mon+=1;
$mday="0".$mday if ($mday<10);
$mon="0".$mon if ($mon<10);
$hour="0".$hour if ($hour<10);
$min="0".$min if ($min<10);
$sec="0".$sec if ($sec<10);
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.