06 Jan 2005 02:19:39 UTC
- Distribution: Lingua-EN-Numbers
- Module version: 1.01
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (2)
- Testers (1448 / 1 / 0)
- KwaliteeBus factor: 1
- License: unknown
- Activity24 month
- Download (7.29KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
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";
You have two hundred and thirty-four things to do today! You will stop caring after the fifty-fourth.
Lingua::EN::Numbers turns numbers into English text. It exports (upon request) two functions,
num2en_ordinal. Each takes a scalar value and returns a scalar value. The return value is the English text expressing that number; or if what you provided wasn't a number, then they return undef.
This module can handle integers like "12" or "-3" and real numbers like "53.19".
This module also understands exponential notation -- it turns "4E9" into "four times ten to the ninth"). And it even turns "INF", "-INF", "NaN" into "infinity", "negative infinity", and "not a number", respectively.
Any commas in the input numbers are ignored.
For some amount of backward compatability with the old (before 1.01) version of this module, the old OO interface is supported, where you can construct a number object with
new([optionalvalue]), change its value with
parse(value), and get its Engish expression with
The rest of the old version's interface (like $Lingua::EN::Numbers::MODE and the other $Lingua::EN::Numbers::ALLCAPS variables) are no longer supported. This is not a great loss, as much of that stuff never worked right in the first place.
Copyright (c) 2005, Sean M. Burke, author of the later versions.
This library is free software; you can redistribute it and/or modify it only under the terms of version 2 of the GNU General Public License (perlgpl).
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
(But if you have any problems with this library, I ask that you let me know.)
Sean M. Burke, firstname.lastname@example.org
(The author of the 0.01 version was Stephen Pandich.)
Module Install Instructions
To install Lingua::EN::Numbers, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Lingua::EN::Numbers
For more information on module installation, please visit the detailed CPAN module installation guide.