in reply to ternary operator ?
The ternary ?: is a short if-then-else:
A ? B : C # is equivalent to if ( A ) { B } else { C }
The advantage is that it's an expression, in contrast to if-else, which is a control structure. So.
print A ? B : C; #correct # equivalent if-else? print if(A){ B }else{ C }; #nope # does the same, but doesn't mean the same: if( A ){ print B } else { print C }
HTH. See perlop for further enlightment.
--
|
|---|