But what does the syntactically correct statement
$expression ? $var = "foo" : $var = "bar";
actually do?
>perl -wMstrict -le
"for my $expression (0, 1) {
my $var = '';
$expression ? $var = 'foo' : $var = 'bar';
print qq{if \$expression is $expression, \$var is '$var'}
}
"
if $expression is 0, $var is 'bar'
if $expression is 1, $var is 'bar'
It seems the statement is just an expensive equivalent to the statement
$var = 'bar';
The reason why is left as a exercise for simonz (after the recommended perusal of perlop :)