tags:

views:

293

answers:

4

I need some code in my program which takes a number as input and converts it into corresponding text e.g. 745 to "seven hundred forty five".

Now, I can write code for this, but is there any library or existing code I can use?

+1  A: 

Take a look at the Math::BigInt::Named module.

innaM
A: 

Also take a look at Nums2Words.

Anand
+2  A: 

You need to look at this stackoverflow question

From the above-mentioned link:

perl -MNumber::Spell -e 'print spell_number(2);'
Aamir
+12  A: 

From perldoc of Lingua::EN::Numbers:

use Lingua::EN::Numbers qw(num2en num2en_ordinal);

my $x = 234;
my $y = 54;
print "You have ", num2en($x), " things to do today!\n";
print "You will stop caring after the ", num2en_ordinal($y), ".\n";

prints:

You have two hundred and thirty-four things to do today!
You will stop caring after the fifty-fourth.
depesz