in reply to localtime()

Instead of 25 lines to format the date, try 1:
use POSIX 'strftime'; my $now_string = strftime( "%Y%m%d", localtime );
For the previous day's, use localtime(time - 86400) as merlyn points out. If the daylight savings time thing will be a problem, have a look at Date::Calc or even Time::Local (in the core distribution).

blokhead

Replies are listed 'Best First'.
Re^2: localtime()
by LeeC79 (Acolyte) on Jul 19, 2004 at 12:59 UTC
    Thanks blockhead! And thanks to everyone for pointing out my use of "bad" code. I'm new to perl and am still learning. The two lines below are much better then what I was doing before, thanks again.
    use POSIX 'strftime'; my $now_string = strftime( "%Y%m%d", localtime(time - 86400));