NAME
Tie::Plural - Select a string variant based on a quantity.
VERSION
This documentation describes version 0.01 of Plural.pm, January 07, 2005.
SYNOPSIS
$var = $pl{$num};
$var = $pl{$num, $plural};
$var = $pl{$num, $plural, $singular};
$var = $pl{$num, $plural, $singular, $zero};
$var = plural($num);
$var = plural($num, $plural);
$var = plural($num, $plural, $singular);
$var = plural($num, $plural, $singular, $zero);
DESCRIPTION
This module provides a simple way to pluralize words within strings. More precisely, it provides a way to select a string from a number of choices based on a quantity. This is accomplished by a tied hash, so it is very easy to incorporate these choices into output strings, which is generally where you need them.
VARIABLES
- %pl
 - 
$variant = $pl{$number, $plural_form, $singular_form, $zero_form};Based on
$number, returns one of$plural_form,$singular_form, or$zero_form. If$numberis 0,$zero_formis returned. If$numberis 1,$singular_formis returned. Otherwise,$plural_formis returned.Only
$numberis required.$plural_formdefaults to 's'.$singular_formdefaults to '' (the empty string).$zero_formdefaults to whatever$plural_formis. 
FUNCTIONS
- plural
 - 
$variant = plural($number, $plural_form, $singular_form, $zero_form);Based on
$number, returns one of the other arguments. Works the same as the%pltied-hash does.This function is not exported by default.
 
EXAMPLES
for $num (0..3)
{
    print "I have $num dog$pl{$num}.\n";
}
# The above prints:
 I have 0 dogs.
 I have 1 dog.
 I have 2 dogs.
 I have 3 dogs.
$num = 700;
print "My wife owns $pl{$num,'many','one','no'} dress$pl{$num,'es'}.";
#
"My wife owns many dresses."
EXPORTS
The variable %pl is exported by default. The function plural is available for export. The tag :all will export all available symbols into your namespace.
SEE ALSO
Damian Conway's excellent Lingua::EN::Inflect provides a much more full-featured way to produce plural forms automagically.
AUTHOR / COPYRIGHT
Eric J. Roode, roode@cpan.org
Copyright (c) 2005 by Eric J. Roode. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.