You can probably figure out easily how to make a plural of a word in the English language, and when to put a or an as the indefinite article. However, it’s not that easy when you need to do that dinamically on words provided by an user or coming from some other source. Also, you have no elegant way to automatically print something like this:
with a single print statement. Lingua::EN::Inflect provides all these features, so it allows to write proper English plurals even when you don’t know the words you have to inflect. Just say:
The output of this code is exactly the text shown above. Even though this is a very useful feature, Lingua::EN::Inflect offers many more utilities to work with plurals in the English language. Keep on reading to discover the gory details.
Let’s analyze the formation of the plurals. The module uses some rules to generate them properly. For instance:
correctly displays:
thus adding ‘s’ or ‘es’ depending on the structure of the singular word. It’s not all about nouns, as the moule also supports the plural for verbs and adjectives. i.e.:
prints:
So, you just pass to the functions the demonstrative adjective, the noun and the verb in their singular form (the verb has got be conjugated in the desired tense and person) to get the correct inflections. Numerical adjectives (a => some) are also handled, and so are pronouns:
magically outputs this:
Is this module beginning to seem very useful to you? Well, it is. Maybe you’re the “nostalgic” folk who likes the old-style plurals some words offer (I do). Since these ancient plurals are perfectly correct even in current English, you can get them:
Have a look at the poetic output:
As you see, Lingua::EN::Inflect solves almost every problem you might encounter while creating plurals for English words you don’t know when writing you Perl code. Also, it helps you with plurals of pronouns and adjectives, so that you’re not forced to write a lot of if statements to get things done properly. The situations you can manage using this module are really countless:
So, this is another of the many ways in which Perl can save you a lot of coding time. Lingua::EN::Inflect provides also some other features (take a look at the module documentation), and it is also easily extensible with your rules and exceptions (the author knows the module might not be perfect and probably does not cover everything).
Happy inflecting!