use strict; use warnings; my $startDate = q{2007-11-23}; my $endDate = q{2008-04-12}; my $leap = isLeap( ( split m{-}, $startDate )[ 0 ] ); my @dates = ( $startDate ); while( $startDate ne $endDate ) { $startDate = incByOneDay( $startDate ); push @dates, $startDate; } print do{ local $" = qq{\n}; qq{@dates\n}; }; sub incByOneDay { my $raDaysInMonth = [ [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ], [ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ], ]; my( $y, $m, $d ) = split m{-}, $_[ 0 ]; $d ++; $d = 1, $m ++ if $d > $raDaysInMonth->[ $leap ]->[ $m ]; $m = 1, $y ++, $leap = isLeap( $y ) if $m > 12; return sprintf q{%04d-%02d-%02d}, $y, $m, $d; } sub isLeap { my $year = shift; return 0 if $year % 4; return 1 if $year % 100; return 1 unless $year % 400; return 0; }