![]() |
|
Keep It Simple, Stupid | |
PerlMonks |
Re: Why does the Perl conditional operator not do what I expect?by why_bird (Pilgrim) |
on Apr 20, 2009 at 10:59 UTC ( #758668=note: print w/replies, xml ) | Need Help?? |
I am always tripping up over this, and like betterworld says, parentheses are the answer. I believe this also works, and may be slightly easier to get your head around/remember (it is for me anyway).
btw from previous experience, I found it quite difficult to super search or google for advice on this construct, as most search engines do not recognise most punctuation, and I for one did not know it was called 'ternary ?'. update: p.s. in response to linuxer, say you wanted to do $condition ? $a=2 : $b=3, would ($condition) ? ($a=2) : ($b=3) then be the correct/advisible way to do it? cheerswhy_bird Those are my principles. If you don't like them I have others. -- Groucho Marx .......
In Section
Seekers of Perl Wisdom
|
|