#!/usr/bin/perl use strict; use warnings; use Date::Calc qw/Days_in_Month Day_of_Week/; my @days_of_week = qw/NULL Mon Tue Wed Thu Fri Sat Sun/; my $i=0; # Our 14 calendars are in these years, this century # see: http://www.koshko.com/calendar/calendar-lookup-gregorian.shtml for (6, 7, 1, 2, 3, 10, 11, 12, 24, 8, 20, 4, 16, 0) { my $year=$_+2000; $i++; my %days_of_month; for my $month_of_year(1 .. 12) { my $sday = Day_of_Week($year,$month_of_year,1); # only need to call this once for my $day_of_month(1 .. Days_in_Month($year,$month_of_year)) { $sday = 1 if($sday>7); my $dow = $sday++; $days_of_month{$day_of_month}{$dow}++; } } for my $day_of_month (sort keys %days_of_month) { next if(scalar keys %{$days_of_month{$day_of_month}} == 7); my @missing_days; for (1..7) { push (@missing_days, $days_of_week[$_]) if !defined $days_of_month{$day_of_month}{$_}; } print "Calendar $i: In $year, Day $day_of_month does not fall on ", join(", ", @missing_days), "\n"; } }