Given the following code, if I were to want $day, $month, $hour, $minute
& $sec to have a leading zero (ie 01 for Jan rather than 1), is my only
option to use printf? Or is there a better way.
What I'm searching for here is the *correct* method to get $day, $month,
etc for uses like naming backup files (databackup-2007-01-21.tar.gz).
Thanks,
Mike
#!/usr/bin/perl
use strict;
use warnings;
my($sec, $min, $hour, $day, $month, $year)=(localtime)[0 .. 5];
print "day=$day\n";
print "month=".($month+1)."\n";
print "year=".($year+1900)."\n\n";
print "hour=$hour\n";
print "minute=$min\n";
print "second=$sec\n\n";
--
If I had it all to do over again, I'd spell creat with an "e". -
Kernighan
02:10:01 up 7 days, 12:47, 0 users, load average: 0.49, 0.24, 0.15
Linux Registered User #241685 http://counter.li.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/