First off, kudos on that regex. Very spiffy. Are you aware of qr/REGEX/ in newer Perls?

As to the problem at hand, yes, you're going to have to use capturing parens and manipulate the results. Something like the following in your if condition:

if ((($month, $day, $year) = /($month)($day)($year)/io) || (($day, $month, $year) = /($day)($month)($year)/io)) { .... }

Then, the question becomes, what goes in the "...."? I'll assume you have a plan in mind for $year, and $day doesn't require anything unless you want to do verification. My suggestion for $month is a hash that looks something like this:

JANUARY => 'Jan', FEB => 'Feb', FEBRUARY => 'Feb', .... DEC => 'Dec', DECEMBER => 'Dec');

Then you can so something like:

printf('%02d-%s-%04d', $day, $mhash{uc $month}, $my_year);

where $my_year is something you calculated from $year.

Of course, if you want to validate the day first, you could augment %mhash something like this:

my %mhash = (JAN => {Name => 'Jan', Days => 31}, ....

And print like so:

printf('%02d-%s-%04d', $day, $mhash{uc $month}{Name}, $my_year);

That was probably more answer than you needed, but there ya go.

*Woof*


In reply to Re: Data normalisation by splinky
in thread Data normalisation by Perl-chick

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.