in reply to What does the ternary statement actually do?
Suitably described above. There is one handy case not mentioned as I begin to type this
$bobscats=2; $billscats=1; printf "Bob has %s\n", catstat($bobscats); printf "Bill has %s\n", catstat($billscats); sub catstat { my($count)=@_; sprintf "%d %s", $count, $count>1?'cats':'cat'; }
will print out Bob has 2 cats
Bill has 1 cat
So that it doesn't appear that you aren't sure how to say things like xxx has 1 cat(s)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What does the ternary statement actually do?
by tadman (Prior) on Aug 13, 2001 at 07:18 UTC |