in reply to Data normalisation
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Data normalisation
by splinky (Hermit) on Jul 06, 2000 at 17:46 UTC |