Gerald Wheeler wrote:
Gunnar Hjalmarsson wrote:

    use Time::Local;

    sub nextday {
        my ($y, $m, $d) = split /\//, shift;
        my $t = timegm 0, 0, 0, $d, $m-1, $y;
        ($d, $m, $y) = ( gmtime($t+24*60*60) )[3..5];
        sprintf '%d/%02d/%02d', $y+1900, $m+1, $d;
    }

    print nextday('2007/11/20');

   I checked and find that I do have the Time::Local module installed

You should have, since it's a standard module that comes with Perl.

The problem is ... how do I increment the day from start to end of the
calendar year?

If i initially set nextday to: 2007/01/01 how do i easily increment
this?

You don't _set_ nextday to anything. You _pass_ a date, e.g. '2007/01/01', to the function nextday(), which _returns_ the next date. This is an example use of the function:

    my $date = '2007/01/01';

    while ( substr($date, 0, 4) eq '2007' ) {
        print "$date\n";
        $date = nextday($date);
    }

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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


Reply via email to