my $value = (if condition? then this: else this);
That's about the quickest explanation. Ternary should never be used in void context. See my node Ternary in void context where I cleared up my ternary confusion as well. The ternary operator always returns the value present in its truth branch (for lack of a better term), that's why you shouldn't substitute it for if then constructs.
an if then construct that warrants a ternary is similar to the following
if($some_var eq 'X')
{
$this_var = 'Run using X format';
}
else
{
$this_var = 'Run using standard format';
}
This would equate to the ternary
$this_var = ($some_var eq 'X'? 'Run using X format':'Run using standar
+d format');
|