Harry Putnam wrote:
>
> I really have two questions here:
>
> 1) How can I get padded numbers in the single digit range in this
> script?
perldoc -f sprintf
perldoc -f printf
perldoc POSIX # look for the strftime function
> 2) Hoping tbis isn't some glaring mistake and I'm too blind to see it.
> Notice how the month is off by 1
perldoc -f localtime
[snip]
specified time. $mday is the day of the month,
and $mon is the month itself, in the range `0..11'
with 0 indicating January and 11 indicating
December. $year is the number of years since
> cat test.pl
>
> #!/usr/local/bin/perl -w
> $now = time;
> ## 1 day = 86400
>
> $date_spec = ($now - 86400);
> # local time adjusted
> @lta = localtime($date_spec);
>
> # 0=second
> # 1=minute
> # 2=hour
> # 3=day of mnth
> # 5=year
> # 4=mnth
> # 6=day of week
>
> print " $lta[4]/$lta[3]/" . ($lta[5] += 1900) . " $lta[2]:$lta[1]:$lta[0]\n";
> print localtime() . "\n";
>
> OUTPUT:
>
> 11/14/2002 20:9:4
> Sun Dec 15 20:09:04 2002
>
> Notice how the bare print on `localtime()' gives the desired padding.
> Notice how the eleventh mnth is reported in the adjusted time.
printf " %02d/%02d/%04d %02d:%02d:%02d\n", $lta[4] + 1, $lta[3], $lta[5] + 1900,
@lta[2,1,0];
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]