Good work, it's been a pleasure seeing you develop this. Now the assignment is in, I'll show you how I'd do it. The basic principle I'll use is to get the input into some fixed order as soon as possible.

You could simplify it a bit by making split more ambitious, splitting on either whitespace or '/', my @dateparts = split '/|\s+', $date; Now decide if we have a named month second (08 Apr 1984), and reorder if so, @dateparts[0,1] = @dateparts[1,0] if $dateparts[1] =~ /^[A-Z]/; Lets collect the year logic in one place,

$dateparts[2] += ($dateparts[2] > 99) ? 0 : ($dateparts[2] > 9) ? 1900 : 2000;
Now sanity check the month exists $months{$dateparts[0]} or die 'Bad Month!'; It would be good to check the day against the number of days in the month - an exercise for you. Don't forget leap years ;-) We now have put the dateparts array in a set format and we can do what we like with it,
print $months{$dateparts[0]}, ' ', 0+$dateparts[1], ', ', dateparts[2];
For real work, I'd shove the numerical forms into a localtime-like array and call POSIX::strftime() on it for string formatting.

After Compline,
Zaxo


In reply to Re: Final date conversion happiness script by Zaxo
in thread Final date conversion happiness script by ctp

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.