No such thing as a small change | |
PerlMonks |
Re^7: Short form (ternary) if elseby wrog (Friar) |
on Feb 08, 2012 at 23:32 UTC ( [id://952623]=note: print w/replies, xml ) | Need Help?? |
operator precedence; ? : binds tighter than =. So
1 ? $x=1 : $x=0 really means (1 ? $x=1 : $x)=0 which is then the same as ($x=1)=0
which is why $x becomes 0.
1 ? $x=1 : ($x=0)
In Section
Seekers of Perl Wisdom
|
|