in reply to Re: date span in YYYYMMDD
in thread date span in YYYYMMDD

To deal with leap years, you could make the @days array like this:

my @days = ( [ qw(31 28 31 30 31 30 31 31 30 31 30 31) ], # non-leap [ qw(31 29 31 30 31 30 31 31 30 31 30 31) ] # leap )

A function to return 0 when a gives year is not a leap year, and 1 if it is:

sub leap { my $y = shift; return ($y % 4 == 0 && $y % 100 != 0) || $y % 400 == 0; }
and you can use it like
my $leap = leap($y); ... $days[$leap][$m]

Arjen