And this is a DateTime solution:
#!/usr/bin/perl -l
use DateTime;
use DateTime::Duration;
my $date = DateTime->new(
year => 2006,
month => 12,
day => 31,
locale => 'en_US',
);
my $duration = DateTime::Duration->new(
months => 1,
end_of_month => 'preserve',
);
for ( 1..12 ) {
$date->add( $duration ); # One month more
print $date->mdy('/'); # And show it
}
Updated: With
Ponky advice, rest:
use DateTime;
my $date = DateTime->last_day_of_month( year => 2006, month => 12 );
print $date->add( months => 1, end_of_month => 'preserve' )->mdy('/')
+foreach 1..12;