in reply to Re: Data normalisation
in thread Data normalisation

This is a very good point, Ovid. Sometimes the easiest solution may not be the most maintenable one. In fact, putting the grouping parenthesis in the regex instead of in the variable assignments only adds a little bit of postprocessing. You only need to remove the possible suffixes from $day. So something like this would work:
if (( ($m, $d, $y) = (/($month)($day)($year)/io) ) || ( ($d, $m, $y) = (/($day)($month)($year)/io) ) ) { $y += 1900 if $y < 100; $m = substr($m, 1, 3); $d =~ s/^(\d+).*$/$1/; print "$d-$m-$y\n"; }
Another thing I noticed is that we had been happily assigning the matching strings to the same variables used to hold the regular expressions. Not good. So I renamed the variables in this new code segment.

--ZZamboni

Replies are listed 'Best First'.
RE: RE: Re: Data normalisation
by Ovid (Cardinal) on Jul 06, 2000 at 21:21 UTC
    We had been happily assigning the matching strings to the same variables used to hold the regular expressions.

    ROTFL!!! I can't stop laughing over this one. Whups!! :)