M. Lewis wrote: > > 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"; > > use POSIX 'strftime';
my $dd = strftime "%Y-%m-%d",localtime; my $backup = "databackup-.$dd."tar.gz""; goksie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/