in reply to Re: Improve my Code: Date List
in thread Improve my Code: Date List

I do want to reinvent wheels until I understand the wheel well enough to trust someone else's.

Replies are listed 'Best First'.
Re^3: Improve my Code: Date List
by Anonymous Monk on Jun 18, 2009 at 00:28 UTC
    why dont use already existing date modules Eg:- Date::Calc For instance the code can be simplified to
    use strict;
    use warnings;
    use Date::Calc qw(Today Add_Delta_Days);
    
    my $today = sprintf("%02d%02d%02d",Today());
    
    my $year = 1986;
    my $month = 1;
    my $day = 1;
    my $offset =0 ;
    my $print_date = 0;
    
    while ($today > $print_date){
            my ($new_year,$new_month,$new_day)= Add_Delta_Days($year,$month,$day, $offset);
            $print_date =  sprintf("%02d%02d%02d",$new_year,$new_month,$new_day);
            print "$print_date\n";
            $offset++;
    }
    
    
    Depending on your req you can alter where ever needed
    Cheers