in reply to Re: What does the ternary statement actually do?
in thread What does the ternary statement actually do?

In C mode, that's what I usually do, only slightly different:
printf ("%d %s%s\n", $count, "cat", ($count==1)?"":"s"); printf ("%d %s%s\n", $count, "cact", ($count==1)?"us":"i"); printf ("%d %s%s\n", $count, "Elvi", ($count==1)?"s":"i");
As an alternative, you might want to use:
print $count, "cat", (($count==1)?"":"s"), "\n"; print $count, "cact", (($count==1)?"us":"i"), "\n"; print $count, "Elvi", (($count==1)?"s":"i"), "\n";
Or perhaps as a method:
sub quantize { my ($quantity, $singular, $plural) = @_; return (1==$quantity)? $singular : $plural; } $count = 2; print "$count @{[quantize($count,'cat','cats')]}\n";