1Lingua::EN::Numbers(3)User Contributed Perl DocumentationLingua::EN::Numbers(3)
2
3
4
6 Lingua::EN::Numbers - turn "407" into "four hundred and seven", etc.
7
9 use Lingua::EN::Numbers qw(num2en num2en_ordinal);
10
11 my $x = 234;
12 my $y = 54;
13 print "You have ", num2en($x), " things to do today!\n";
14 print "You will stop caring after the ", num2en_ordinal($y), ".\n";
15
16 prints:
17
18 You have two hundred and thirty-four things to do today!
19 You will stop caring after the fifty-fourth.
20
22 This module provides a function "num2en", which converts a number (such
23 as 123) into English text ("one hundred and twenty-three"). It also
24 provides a function "num2en_ordinal", which converts a number into the
25 ordinal form in words, so 54 becomes "fifty-fourth".
26
27 If you pass either function something that doesn't look like a number,
28 they will return "undef".
29
30 This module can handle integers like "12" or "-3" and real numbers like
31 "53.19".
32
33 This module also understands exponential notation -- it turns "4E9"
34 into "four times ten to the ninth"). And it even turns "INF", "-INF",
35 "NaN" into "infinity", "negative infinity", and "not a number",
36 respectively.
37
38 Any commas in the input numbers are ignored.
39
41 The first version of this module, 0.01 released in May 1995, had an OO
42 interface. This was finally dropped in the 1.08 release.
43
45 <http://neilb.org/reviews/spell-numbers.html> - a review of CPAN
46 modules for converting numbers into English words.
47
48 The following modules will convert a number into words:
49
50 · Lingua::EN::Inflect provides a lot more besides, including
51 conversion of singular to plural, selecting whether to use 'an' or
52 'a' before a word, and plenty more
53
54 · Lingua::EN::Nums2Words provides similar functionality, but can't
55 handle exponential notation, and 3.14 produces "three and fourteen
56 hundredths" instead of "three point one four".
57
58 · Math::BigInt::Named doesn't work.
59
60 · Number::Spell doesn't handle negative numbers, exponential
61 notation, or non-integer real numbers. The generated text doesn't
62 contain any commas or the word 'and', so the results for long
63 numbers don't scan.
64
65 There are other modules which provide related, but not identical,
66 functionality:
67
68 · Lingua::EN::Numbers::Ordinate provides a function that will convert
69 a cardinal number (such as "3") to an ordinal ("3rd").
70
71 · Lingua::EN::Numbers::Years provides a function that will convert a
72 year in numerals (eg "1984") into words ("nineteen eighty-four").
73
74 · Lingua::EN::Fractions provides a function that will convert a
75 numeric fraction (eg "3/4") into words ("three quarters").
76
78 <https://github.com/neilb/Lingua-EN-Numbers>
79
81 Copyright (c) 2005, Sean M. Burke.
82
83 Copyright (c) 2011-2013, Neil Bowers, minor changes in 1.02 and later.
84
85 This library is free software; you can redistribute it and/or modify it
86 only under the terms of version 2 of the GNU General Public License
87 (perlgpl).
88
89 This program is distributed in the hope that it will be useful, but
90 without any warranty; without even the implied warranty of
91 merchantability or fitness for a particular purpose.
92
93 (But if you have any problems with this library, I ask that you let me
94 know.)
95
97 The first release to CPAN, 0.01, was written by Stephen Pandich in
98 1999.
99
100 Sean M Burke took over maintenance in 2005, and completely rewrote the
101 module, releasing versions 0.02 and 1.01.
102
103 Neil Bowers <neilb@cpan.org> has been maintaining the module since
104 2011.
105
106
107
108perl v5.28.0 2015-11-07 Lingua::EN::Numbers(3)