in reply to how do I issue e-mail using perl? (was:Help)

Another thing to find out would be how your putting the date into the data file. That's something we would need to know to figure out the "prior date" portion.

I can't come up with a quick non-CPAN way to do that to cover Dec 31 -> Jan 1 changes, and also lastday(month)->firstday(nextmonth) changes.

Any folks have any ideas on how to parse the date, assuming they're stored as MM/DD/YYYY (if they're separated fields, they can be join()'d, and if DD/MM/YYYY or some other format, it should be easily changable to MM/DD/YYYY)? Dates are probably one of the most irritating things when it comes to programming. =]

-marius

Replies are listed 'Best First'.
(jeffa) Re: Re: Help
by jeffa (Bishop) on Dec 06, 2000 at 22:06 UTC
    I think this will do the trick:
    use strict; use Time::Local; my $time = timelocal(localtime); $time -= (60 * 60 * 24); # subtract one day my ($s, $min, $h, $d, $mon, $y, $w, $yd, $isdst) = localtime($time); printf("Yesterday's date: %02d:%02d:%02d-%04d/%02d/%02d\n", $h, $min, $s, $y+1900, $mon+1, $d);
    The trick is to work in Epoch seconds, and let localtime figure out what the date is.

    Jeff

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    F--F--F--F--F--F--F--F--
    (the triplet paradiddle)