On 2/3/07, Mathew Snyder <[EMAIL PROTECTED]> wrote:

my @date     = (localtime)[3..5];
my $day      = sprintf '%02d', $date[0] - 1;
my $month    = sprintf '%02d', $date[1] + 1;

You shouldn't have to do arithmetic on the date components, including
all that mess about how many days are in a month. That's hard to get
right; besides, somebody else has debugged all that already. Do the
arithmetic on the time, instead, and you'll have the right date:

   my @date = (localtime (time - 24*60*60) )[3..5];  # 24 hours ago
was yesterday

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to