in reply to one-line conditional print?

Consider Text::Pluralize.

print pluralize "There (is|are) (no|one|%d) slice(s) of pizza left.", $count);

Q.E.D.

Note that this strategy, “slick” though it is, may or may not be appropriate for languages other than English. It is not a general “I18N” solution.

Replies are listed 'Best First'.
Re^2: one-line conditional print?
by jpl (Monk) on May 17, 2011 at 12:09 UTC
    Interesting module (it's pointers like this that keep me hanging around the monastery). Tiny quibble: you need curlies to have a 0-based index.
    print pluralize "There (is|are) (no|one|%d) slice(s) of pizza left.", +0; There are 0 slices of pizza left. print pluralize "There (is|are) (no|one|%d) slice(s) of pizza left.", +1 There is no slice of pizza left. print pluralize "There (is|are) {no|one|%d} slice(s) of pizza left.", +0; There are no slices of pizza left.