example:
various results:&pluralize($items); print "$items item$plur listed"; sub pluralize{ my $var = shift(@_); if($var==1){$plur=""} else {$plur="s"} }
Update: This topic is also covered in Perl Cookbook recipe 2.18. Printing Correct Plurals which has solutions using printf, Lingua::EN::Inflect, and (naughty) regexps.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Pluralize nouns
by turnstep (Parson) on Dec 11, 2000 at 17:03 UTC | |
Re: Pluralize nouns
by chipmunk (Parson) on Dec 11, 2000 at 20:35 UTC | |
Re: Pluralize nouns
by extremely (Priest) on Dec 11, 2000 at 13:58 UTC | |
by epoptai (Curate) on Dec 11, 2000 at 14:16 UTC | |
Re: Pluralize nouns
by I0 (Priest) on Dec 12, 2000 at 10:06 UTC |