use strict; use warnings; use Time::Piece; use Time::Seconds; my $t = Time::Piece->strptime( '2015-01-01', '%Y-%m-%d' ); my @calendar = (); my $count = 0; # 2015年のカレンダー作成 while (1) { push @calendar, $t->strftime('%m%d'); last if ( $t->ymd eq '2015-12-31' ); $t = $t + ONE_DAY; } for my $date (@calendar){ my $month = substr($date,0,2); my $date_ten = substr($date,2,1); my $date_one = substr($date,3,1); if ($month == ($date_ten + $date_one) ){ print $date , "\n"; $count++; } } print $count , "\n"