NAME
Lingua::EN::Numbers - Converts numeric values into their English string equivalents.
SYNOPSIS
## EXAMPLE 1
use Lingua::EN::Numbers qw(American);
$n = new Lingua::EN::Numbers(313721.23);
if (defined $n) {
$s = $n->get_string;
print "$s\n";
}
## EXAMPLE 2
use Lingua::EN::Numbers;
$n = new Lingua::EN::Numbers;
$n->parse(-1281);
print "N = " . $n->get_string . "\n";
REQUIRES
Perl 5, Exporter, Carp
DESCRIPTION
Lingua::EN::Numbers converts arbitrary numbers into human-oriented English text. Limited support is included for parsing standardly formatted numbers (i.e. '3,213.23'). But no attempt has been made to handle any complex formats. Support for multiple variants of English are supported. Currently only "American" formatting is supported.
To use the class, an instance is generated. The instance is then loaded with a number. This can occur either during construction of the instance or later, via a call to the parse method. The number is then analyzed and parsed into the english text equivalent.
The instance, now initialized, can be converted into a string, via the get_string method. This method takes the parsed data and converts it from a data structure into a formatted string. Elements of the string's formatting can be tweaked between calls to the get_string function. While such changes are unlikely, this has been done simply to provide maximum flexability.
METHODS
Creation
Initialization
Output
CLASS VARIABLES
- $Lingua::EN::Numbers::VERSION
-
The version of this class.
- $Lingua::EN::Numbers::MODE
-
The current locale mode. Currently only American is supported.
- %Lingua::EN::Numbers::INPUT_GROUP_DELIMITER
-
The delimiter which seperates number groups. Example: "1,321,323" uses the comma ',' as the group delimiter.
- %Lingua::EN::Numbers::INPUT_DECIMAL_DELIMITER
-
The delimiter which seperates the main number from its decimal part. Example: "132.2" uses the period '.' as the decimal delimiter.
- %Lingua::EN::Numbers::OUTPUT_BLOCK_DELIMITER
-
A character used at output time to convert the number into a string. Example: One Thousand, Two-Hundred and Twenty-Two point Four. Uses the space character ' ' as the block delimiter.
- %Lingua::EN::Numbers::OUTPUT_GROUP_DELIMITER
-
A character used at output time to convert the number into a string. Example: One Thousand, Two-Hundred and Twenty-Two point Four. Uses the comma ',' character as the group delimiter.
- %Lingua::EN::Numbers::OUTPUT_NUMBER_DELIMITER
-
A character used at output time to convert the number into a string. Example: One Thousand, Two-Hundred and Twenty-Two point Four. Uses the dash '-' character as the number delimiter.
- %Lingua::EN::Numbers::OUTPUT_DECIMAL_DELIMITER
-
A character used at output time to convert the number into a string. Example: One Thousand, Two-Hundred and Twenty-Two point Four. Uses the 'point' string as the decimal delimiter.
- %Lingua::EN::Numbers::NUMBER_NAMES
-
A list of names for numbers.
- %Lingua::EN::Numbers::SIGN_NAMES
-
A list of names for positive and negative signs.
- $Lingua::EN::Numbers::SIGN_POSITIVE
-
A constant indicating the the current number is positive.
- $Lingua::EN::Numbers::SIGN_NEGATIVE
-
A constant indicating the the current number is negative.
DIAGNOSTICS
- Error: Lingua::EN::Numbers does not support tag: '$tag'.
-
(F) The module has been invoked with an invalid locale.
- Error: bad number format: '$number'.
-
(F) The number specified is not in a valid numeric format.
- Error: bad number format: '.$number'.
-
(F) The decimal portion of number specified is not in a valid numeric format.
AUTHOR
Stephen Pandich, pandich@yahoo.com