Rpaguilar has asked for the wisdom of the Perl Monks concerning the following question:

I’m really puzzled with this pattern matching thing…as a beginner in Perl I’m doing a simple HTML form where you have a textbox and some test data in it with text and dates like 03/11/02, 03-11-02 or 03/11/2002. And the thing is I’ve got to get another HTML page with all the data entered in the text field but with the respective dates changed to 3rd November 2002 respectively. I’ve got this code but at the moment it isn’t doing what I want. Regards Ric ##########################################################
#!/cgi-bin/perl -w use CGI; # get the form data $query = new CGI; $textInput=$query->param('textInput'); #start the html page print $query->header; print $query->start_html(-title=>"Ric's"); print "<FONT SIZE='5'>\n"; print "The text entered was:<HR>\n"; print "</FONT>\n"; { print "$textInput<BR>\n"; } ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localt +ime(time); $year =~ s/^\d(\d\d)$/$1/; $mon++; if(length($mon) < 2){$mon = "0" . $mon;} if($year > 90) {$year = "19" . $year;} else{$year = "20" . $year;} if($min < 10){$min= "0$min";} $textInput = "$mday/$mon/$year"; @month = ("-", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); @monthPost = ("-", "st", "nd", "rd", "th", "th", "th", "th", "th", "th +", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "st", "nd", "rd", "th", "th", "th" +, "th", "th", "th", "th", "st"); $textInput = "$mday$monthPost[$mday] $month[$mon] $year"; print "$textInput";

Replies are listed 'Best First'.
Re: Date pattern matching
by grep (Monsignor) on Nov 03, 2002 at 21:34 UTC
    Since you stated this is homework in Date pattern matching and that you are not allowed external modules (not reinventing good modules is the correct way) - I am only going to give a nudge in the right direction.

    Don't use a regex, use split, as how to do that I am going to leave that up to you. That should get you what you want most of the time



    grep
    Mynd you, mønk bites Kan be pretti nasti...