Conditional Operator
Ternary "?:" is the conditional operator, just as in C. It works much like an if-then-else. If the argument before the ? is true, the argument before the : is returned, otherwise the argument after the : is returned. For example:
printf "I have %d dog%s.\n", $n,
($n == 1) ? "" : "s";
Scalar or list context propagates downward into the 2nd or 3rd argument, whichever is selected.
$x = $ok ? $y : $z; # get a scalar
@x = $ok ? @y : @z; # get an array
$x = $ok ? @y : @z;