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

I need to convert numbers into word. Ex. if a string is "5 abcs" then I want to make it "Five abcs". Is it possible to do that? Thanks, Paavan

Replies are listed 'Best First'.
Re: Convert number into words
by dragonchild (Archbishop) on May 31, 2005 at 18:26 UTC
    Lingua::Num2Word

    • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
    • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"
      Thanks for your quick response. I cant load Lingua::Num2Word. It tells me it cant find MakeFile.pl.. any ideas why? Thanks, PJ
        • How are you trying to "load Lingua::Num2Word"?
        • What is the exact error message you're seeing?
        • Can you create a minimal test case that contains just enough code to demonstrate the problem?

        • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
        • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"

        Try Makefile.PL if you're on a case-sensitive system. Also try adding a ./ prefix.

Re: Convert number into words
by tchatzi (Acolyte) on May 31, 2005 at 22:43 UTC
    Try on your command prompt
    c:\> ppm install Lingua-Num2Word

    ``The wise man doesn't give the right answers, he poses the right questions.'' TIMTOWTDI
      Thanks. it got installed (I think). Now when I run the script I get following error:

      Undefined subroutine &main::num2en_ordinal called at ConvertNumToWord.pl line 6

      . My program is as follows:
      use Lingua::EN::Numbers; #qw(num2en num2en_ordinal); my $x = 234; my $y = 54; #print "You have ", num2word($x), " things to do today!\n"; print "You will stop caring after the ", num2en_ordinal($y), ".\n";

      Thnks, PJ
        Thanks for you help guys.. here is the code, that I found somewhere online.
        use Lingua::EN::Numbers; use strict; my($numberObject); $numberObject = Lingua::EN::Numbers->new; $numberObject->parse(1234); print $numberObject->get_string . "\n";