Lingua:...:Numbers(3)
π Lingua::EN::Numbers β the Perl page, but make it cute π
okay so bestie, this is Lingua::EN::Numbers, a Perl module from the User Contributed Perl Documentation collection, and it does the most delightful thing ever: it takes a number and says it out loud in English. yes literally. 407 becomes "four hundred and seven". slay.
β¨ NAME β¨
Lingua::EN::Numbers β turn 407 into four hundred and seven, etc. π
π¦ SYNOPSIS π¦
here's the vibe, look at her go:
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";
and it prints:
You have two hundred and thirty-four things to do today!
You will stop caring after the fifty-fourth.
iconic. no notes. π
π DESCRIPTION π
this module hands you a function called num2en, and what it does is take a number (like, say, 123) and turn it into English text ("one hundred and twenty-three"). it's giving translator but make it math.
it ALSO gives you num2en_ordinal, which turns a number into its ordinal form in words β so 54 becomes "fifty-fourth". cute, right?
lowkey important: if you pass either function something that does not look like a number, they will return undef. so check your input bestie, don't be messy. π
here's what this module can handle, fr fr:
- integers like
12or-3 - real numbers like
53.19 - exponential notation β it turns
4E9into"four times ten to the ninth" - and it even turns
INF,-INF, andNaNinto"infinity","negative infinity", and"not a number", respectively. the range?? unmatched. π
also: any commas in the input numbers are just ignored. commas who? never heard of her. π«Ά
πΈ LEGACY INTERFACE πΈ
storytime. the very first version of this module, 0.01, released in May 1995, had an OO interface. very 90s of her. that interface was finally dropped in the 1.08 release. rip to a legend, she's gone now. π
β SEE ALSO β
first up, a whole review situation:
- <http://neilb.org/reviews/spell-numbers.html> β a review of CPAN modules for converting numbers into English words.
then, the modules that will convert a number into words:
Lingua::EN::Inflectβ provides a lot more besides, including conversion of singular to plural, selecting whether to use 'an' or 'a' before a word, and plenty more. she does it all, main character energy fr.Lingua::EN::Nums2Wordsβ provides similar functionality, but can't handle exponential notation, and3.14produces "three and fourteen hundredths" instead of "three point one four". not the vibe honestly. πMath::BigInt::Namedβ doesn't work. that's it. that's the review. πNumber::Spellβ doesn't handle negative numbers, exponential notation, or non-integer real numbers. and the generated text doesn't contain any commas or the word 'and', so the results for long numbers don't scan. no commas?? no 'and'?? bestie that's a crime.
and then there are other modules which provide related, but not identical, functionality:
Lingua::EN::Numbers::Ordinateβ provides a function that will convert a cardinal number (such as"3") to an ordinal ("3rd").Lingua::EN::Numbers::Yearsβ provides a function that will convert a year in numerals (eg"1984") into words ("nineteen eighty-four").Lingua::EN::Fractionsβ provides a function that will convert a numeric fraction (eg"3/4") into words ("three quarters").
π REPOSITORY π
the source lives here, go be nosy:
<https://github.com/neilb/Lingua-EN-Numbers>
π COPYRIGHT π
Copyright (c) 2005, Sean M. Burke.
Copyright (c) 2011-2013, Neil Bowers, minor changes in 1.02 and later.
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.) π«Ά
π AUTHOR π
- The first release to CPAN,
0.01, was written by Stephen Pandich in 1999. - Sean M Burke took over maintenance in 2005, and completely rewrote the module, releasing versions
0.02and1.01. - Neil Bowers
<neilb@cpan.org>has been maintaining the module since 2011.
and that's the whole page bestie, mwah π this one's perl v5.42.0, dated 2025-07-25, and it's the Lingua:...:Numbers(3) page β go forth and spell numbers, you absolute icon π¦β¨πΈ
π¦ where this page comes from
- fedora 43: perl-Lingua-EN-Numbers 2.03-28.fc43 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms