On Fri, Jun 01, 2001 at 03:05:59PM -0400, David Gilden wrote:
[snip -- was there a question about '?:' ?]
> ----printf question--
>
> ### get time
> my($sec, $min, $hour, $mday, $month, $year) = (localtime)[0..5];
> $year += 1900;
> $mday = "0" . $mday if $mday < 10;
> $month++; # perl counts from -1 on occasion
> $month = "0" . $month if $month < 10;
> ####
>
> -- later in the same file --
>
> print TOFILE "On $month/$mday/$year At $hour:$min you wrote:<br>\n\n";
>
> how do I use print to provide a leading '0' to $min, such that
> I get 5:01 and not 5:1
>
Maybe you can just use the output from localtime() in scalar context?
[ ~ ] perl -e 'print scalar localtime,"\n"'
Fri Jun 1 14:13:15 2001
[ ~ ]
Otherwise something like
printf "%02d:%02d:%02d", $hour, $min, $sec;
is likely what you're looking for.
--
Rule #0: Spam is theft.