#!/usr/bin/perl -wl use strict; use Date::Calc 'Nth_Weekday_of_Month_Year'; sub max_days_in_month { my $day = $_[0]; # Monday is 1 my $month = $_[1]; # January is 1 my $year = $_[2]; scalar grep {Nth_Weekday_of_Month_Year($year, $month, $day, $_)} 1..5; } print "There are ", max_days_in_month(1, 6, 2002), " Mondays in June 2002."; print "There are ", max_days_in_month(6, 6, 2002), " Sundays in June 2002."; __END__ Prints: There are 4 Mondays in June 2002. There are 5 Sundays in June 2002. (Good news for those for prefer Sundays to Mondays)