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

1.In a file how do I change the numeric values to word excluded the date format

example 11/12/2009 1 and 2 is done output 11/12/2009 one and two is done

I'll tried to look in the file for the each numeric appears and assign it but still also change the date format

2.How to capitalize the first letter of each word found after AU: marker

sample AU: mark bautista output should be AU: Mark Bautista
my $filename = "input.txt"; open my $file, '<', $filename; @fileinput=<$file>; close($file); foreach $line(@fileinput) { my $Cword=($line); if($Cword=s/(^AU:\s[a-z +]\s\[a-z])/(^AU:\s[A-Z]\s[A-Z])/g) { print $Cword; }

3. there's a date format Oct 27, 2011 change to YYYY/MM/DD output should be 2011/10/27 I having a problem how to change the month in numeric form first then change the format as YYYY/MM/DD.

foreach $line(@fileinput) {my $testdate=($line); if($testdate =~s/(\w{3})\s(\d{2})\,\s(\d{4})/$3\/$1\/$2/) { print $tes +tdate;
but still output the word "Oct" it must be '10' thanks

Replies are listed 'Best First'.
Re: change number to word
by ww (Archbishop) on Mar 20, 2011 at 11:37 UTC
    Specific hints:
    1. Super Search for "dispatch table"
    2. See uc and split
    3. Use modules, such as (for just one sweeping example) Date::Calc

    General hint:

    Questions that merely ask the monks to do your work for you, without showing any effort, are unlikely to get the help requested. Try reading the documentation, tutorials, FAQS, and other info available to you and try writing some code. Then come back and ask -- with your code as part of the post -- specific questions related to specific problems.

    Update: fixed formatting, clarified.

Re: change number to word
by wind (Priest) on Mar 20, 2011 at 16:24 UTC
    There are CPAN modules to solve every one of your stated problems.
    1.In a file how do I change the numeric values to word excluded the date format
    Use Lingua::EN::Numbers.
    use Lingua::EN::Numbers qw(num2en); while (<DATA>) { s/(\d+)/num2en $1/eg; print; } __DATA__ Too Small: 7 and 5. Too Big: 123345 Just right: 51
    2.How to capitalize the first letter of each word found after AU: marker
    Already asked and answered in it's own thread Make the first letter of each word capitalize. Just use Lingua::EN::NameCase.
    3. there's a date format Oct 27, 2011 change to YYYY/MM/DD output should be 2011/10/27 I having a problem how to change the month in numeric form first then change the format as YYYY/MM/DD.
    Use Date::Parse and POSIX:
    use Date::Parse qw(strptime); use POSIX qw(strftime); my $str = 'Oct 27, 2011'; my $newdate = strftime "%Y/%m/%d", strptime $str; print "$newdate\n";

    - Miller

Re: change number to word
by Anonymous Monk on Mar 20, 2011 at 06:51 UTC