Reputation: 11490
I need a Perl script which takes numbers as input example 222 and it should output as two hundred twenty two.
Upvotes: 3
Views: 2615
Reputation: 8352
Use Lingua::EN::Numbers - turn "407" into "four hundred and seven", etc.
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.
If you read the documentation of the module then you will find that the module also support the following things like,
Upvotes: 15
Reputation: 213005
Number::Spell can help you:
use Number::Spell;
my $str = spell_number(222);
Upvotes: 9
Reputation: 382806
Here is one:
Description: This basically converts a number into words. It can only convert numbers less than or equal of novemdecillion quantity. It has a complete input validation process.
Upvotes: -1