in reply to pluralization
Of course, it's gotta be tweaked under certain circumstances:for my $count (0..2) { my $s = (1 == $count)? "": "s"; print "$count iteration$s so far...\n"; }
By the way, the (<constant> == $count) is a habit I picked up from a company which had some good ideas about coding guidelines. (It was for C, but applies to Perl as well). The idea is that you can never accidentally write '=' instead of '==' because the compiler will detect an attempt to assign to a constant and forbid it outright.for my $cheese_eaters (0..2) { my $noun = (1 == $count)? "mouse": "mice"; print "$cheese_eaters $noun so far...\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Rere: pluralization
by Vynce (Friar) on Sep 09, 2005 at 01:57 UTC | |
by liverpole (Monsignor) on Sep 09, 2005 at 02:45 UTC | |
by Vynce (Friar) on Sep 09, 2005 at 03:11 UTC |