I guess you could:
#!/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 cal
+l 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_mon
+th{$day_of_month}{$_};
}
print "Calendar $i: In $year, Day $day_of_month does not fall on "
+, join(", ", @missing_days), "\n";
}
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.