Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I found a a couple of bugs in your code.

First, when I use it today, it prints "Happy 22,023nd unbirthday, dave!" Change the antepenultimate line to:

my $unbirthdays = commify( ORD($days_alive - $birthdays));

Second, if somebody types in "October" for their month of birth, they'll be surprised to see "Sorry, this is not a month"! Change the line:

if ($b_month =~ /0/) {


if ($b_month != 0) {

In fact, I would refactor that bit of code to avoid the programme dying ungraciously if the user enters a non-alphanummeric character:

if ($b_month !~ /^\d+$/) { $b_month = Decode_Month($b_month,1); } if (! $b_month) { print "Sorry, that is not a month.\n"; $b_month = birth_month(); }

Lastly, a minor niggle: 1900, for example, was not a leap year, despite being divisible by 4.

Update: You also seem to have an off-by-one error. If I claim to have been born today, the output is:

Happy 0th unbirthday, dave!

Surely, today should be by first (not 0th) unbirthday?

In reply to Re^3: Happy unbirthday! (To all, with a challenge) by Not_a_Number
in thread Happy unbirthday! by Lady_Aleena

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (4)
    As of 2020-10-31 23:01 GMT
    Find Nodes?
      Voting Booth?
      My favourite web site is:

      Results (291 votes). Check out past polls.