1Words2Nums(3) User Contributed Perl Documentation Words2Nums(3)
2
3
4
6 Lingua::EN::Words2Nums - convert English text to numbers
7
9 use Lingua::EN::Words2Nums;
10 $num=words2nums("two thousand and one");
11 $num=words2nums("twenty-second");
12 $num=words2nums("15 billion, 6 million, and ninteen");
13
15 This module converts English text into numbers. It supports both
16 ordinal and cardinal numbers, negative numbers, and very large numbers.
17
18 The main subroutine, which is exported by default, is words2nums().
19 This subroutine, when fed a string, will attempt to convert it into a
20 number. If it succeeds, the number will be returned. If it fails, it
21 returns undef.
22
24 There are a number of variables that can be used to tweak the behavior
25 of this module. For example, debugging can be be enabled by setting
26 $Lingua::EN::Words2Nums::debug=1
27
28 $Lingua::EN::Words2Nums::debug
29 Default: 0. If set to a true value, outputs on standard error some
30 useful messages if parsing fails for some reason.
31
32 $Lingua::EN::Words2Nums::billion
33 Default: 10 ** 9. This is the number that will be returned for "one
34 billion". It defaults to the American version; the English will
35 want to set it to 10 ** 12. Setting this number automatically
36 changes all the larger numbers (trillion, quadrillion, etc) to
37 match.
38
40 It does not understand decimals or fractions, yet.
41
42 Scores are supported, eg: "four score and ten". So are dozens. So is a
43 baker's dozen. And a gross.
44
45 Various mispellings of numbers are understood.
46
47 While it handles googol correctly, googolplex is too large to fit in
48 perl's standard scalar type, and "inf" will be returned.
49
51 Copyright 2001-2003 Joey Hess <joey@kitenet.net>
52
53 This module is free software; you can redistribute it and/or modify it
54 under the same terms as Perl itself.
55
56
57
58perl v5.38.0 2023-07-20 Words2Nums(3)