go ahead... be a heretic | |
PerlMonks |
Re^3: elsif statement not being evaluatedby afoken (Chancellor) |
on Nov 18, 2012 at 08:35 UTC ( [id://1004386]=note: print w/replies, xml ) | Need Help?? |
Happens to everyone using C or languages inheriting or stealing from C. But you can make the compiler / interpreter complain loudly if you make sure the constant is on the left side of the operator:
This won't help when you compare two variables, but in your case, the variables $an1 and $an2 aren't variable, but constant. So make them constant, either by using Readonly or by using constant:
Or, in this trivial case, get rid of $an1 and $an2 and use 1 and 2. I prefer Readonly over constant, because Readonly just makes the variables readonly, with no surprises, whereas constant (ab)uses the perl optimizer and implements the constants as functions returning a constant value. This has some nasty side effects documented in Readonly. Alexander
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
In Section
Seekers of Perl Wisdom
|
|