On 26 Jan., 17:58, [EMAIL PROTECTED] (Larry Wall) wrote:
> Last night I got a message entitled: "yum: 1 Updates Available".
> Of course, that's probably just a Python programmer giving up on doing
> the right thing, but we see this sort of bletcherousness all the time.
>
> After a recent exchange on PerlMonks about join, I've been thinking
> about the problem of pluralization in interpolated strings, where we
> get things like:
>
>     say "Received $m message{ 1==$m ?? '' !! 's' }."
>
> Any other cute ideas?

When you are a MUD[*]-developer you have to deal with things like this
all the time.
Where I was we did it like this (german sentence converted to perlish
syntax)

   say "{der($player)} nimmt {den($item)} aus {dem($container)}.";

which means:

$player takes $item out of $container

where $player, $item and $container are objects or hashes and der(),
den(), dem() are functions which convert the given object into the
definite nominative, accusative and dative.
There are more functions to implement indefinitive cases and other
grammatical things.

Objects/hashes contain the number, adjectives etc.

To make that more english that could look like:

   say "{nominative($player)} takes {accusative($item)} out of
{dative($container)}.";

With $player={name=>"Paul", adjective=>"great", gender=>"male"},
$item={name=>"ball", count=>3, gender=>"male"},
$container=>{name=>"box", gender=>"male"}, it would interpolate into

   The great Paul take the 3 balls out of the box.

Maybe... btw: in german the gender of the objects also changes
things...

The orignal example
>     say "Received $m message{ 1==$m ?? '' !! 's' }."
could then look like:

say "Recieved {nominative({name=>'message',count=>$m})}."

Maybe someone could find a more concise form if huffmanly desireable.

Regards,
Ron

Reply via email to