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

Hiya!!

I'm currently starting with Perl and I have a problem that I can't find solution. I have a simple html form with a text field and a submit and reset button. When the form is submitted the text in the text area should be displayed as a web page, but with all dates changed that you write in the text area from numeric to word format. Dates in numeric form have three numeric parts (day, month and year) separated by a separator, either "/" or "-". Examples of acceptable numeric dates are 8/11/99, 01/01/00, 1-5-2001. These should be converted to 8th November 1999, 1st January 2000 and 1st April 2001. It should make a suitable rule for determining the centuary for two digit years. You may assume that a date does not split across two lines but note that one line may contain several dates. Also it needs to create a suitable test data, which should be either the default text in the textarea, or which is entered into the text area by clicking a button on the form. If you could help me with a simple script please let me know.
###############################################################
Seeking for wisdom,
Regards,
Ricardo

edit (broquaint): added formatting and removed some #s

Replies are listed 'Best First'.
Re: Date pattern matching
by sharkey (Scribe) on Oct 31, 2002 at 20:08 UTC
    This smells like a homework assignment ("needs to create a suitable test data"?), but I'll give you some hints.

    The limitations on your date string format make it so you can easily parse it with a regular expression. Read the perlre page and about the m// operator, and watch for (capturing), [character sets], and what \d means.

    Once you get the numbers out of the date string, it's pretty menial programming from there. (Month names in an array, etc.)

Re: Date pattern matching
by artist (Parson) on Oct 31, 2002 at 19:26 UTC
    Hi, Welcome to PerlMonks.

    There are modules to do what you have requested. Have a look at Date::Day. You might need to install that module.

    Showing the art of readymade conversion
    artist

      Thanks, but the thing is, I can't use any external modules for that and the link that you gave me is related with a module Regards
        Hi May we know why you cannot use external modules?

        CPAN is a well-known repository of perl modules. Using modules is considered good practice here. It takes some time to understand the module but it saves lot of time and brings the knowledge domain and experties of others to you in very short time. Since you are doing CGI related stuff, I would mention CGI.pm as well.

        Practicing art of using modules,
        Aritst

        What is it that keeps you from using a module?

        Makeshifts last the longest.