http://qs321.pair.com?node_id=1069892


in reply to return value of "if" (documentation?)

For your construction, I'd recommend a chained ternary expression:
print "$_ is ", $_ == 0 ? 'zero' : $_ > 0 ? 'pos' : 'neg', "\n" for -1..1;
The ternary operator ?: is essentially an if statement designed to return a value in a guaranteed-defined way. Breaking this down: I've inserted the line breaks in this particular way to make it easy to see how the chain of logical expressions is evaluated. This also makes it easy to see where to edit new tests in:
print "$_ is ", $_ == 0 ? 'zero' : $_ == 2 ? 'two' : $_ == -1 ? 'minus one' : $_ > 0 ? 'pos' : 'neg', "\n" for -2..2;