The following subroutine isn't a module, but it should work fine pasted anywhere in your code.
use strict; use warnings; print monthdays('Jan',1998), "\n"; print monthdays('FEB',1999), "\n"; print monthdays('FeB',2000), "\n"; print monthdays(2,2100), "\n"; # Takes two arguments, both required: # Month - can be either numerical in the range 0-11, or alphabetic, # ignoring case. # Year - 4-digit format recommended. BEGIN { my %md_mon = ('JAN',1,'FEB',2,'MAR',3,'APR',4,'MAY',5,'JUN',6, 'JUL',7,'AUG',8,'SEP',9,'OCT',10,'NOV',11,'DEC',12); my @md_mon = (0,31,28,31,30,31,30,31,31,30,31,30,31); sub monthdays { my ($m, $y) = @_; $m = $md_mon{uc($m)} if $m =~ /[a-zA-Z]/; my $d = $md_mon[$m]; $d++ if $m == 2 && $y % 4 == 0 && ($y % 100 != 0 || $y % 400 = += 0); return $d; } }

In reply to Re: Finding End of Month's date by TedPride
in thread Finding End of Month's date by neeraj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.