note afoken <p>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:</p> <c> if ($answer=42) { # $answer is now always 42 ... } if (42=$answer) { # "Can't modify constant item in scalar assignment" ... } </c> <p>This won't help when you compare two variables, but in your case, the variables <c>$an1</c> and <c>$an2</c> aren't variable, but constant. So make them constant, either by using [mod://Readonly] or by using [mod://constant]:</p> <c> use Readonly; Readonly my $fortytwo => 42; # note: =>, not = ... if ($fortytwo=$answer) { # "Modification of a read-only value attempted" ... } </c> <c> use constant FORTYTWO => 42; # note: =>, not = ... if (FORTYTWO=$answer) { # "Can't modify constant item in scalar assignment" ... } </c> <p>Or, in this trivial case, get rid of <c>$an1</c> and <c>$an2</c> and use 1 and 2.</p> <p>I prefer [mod://Readonly] over [mod://constant], because <c>Readonly</c> just makes the variables readonly, with no surprises, whereas <c>constant</c> (ab)uses the perl optimizer and implements the constants as functions returning a constant value. This has some nasty side effects [|documented in Readonly].</p> <p>Alexander</p> <div class="pmsig"><div class="pmsig-747201"> --<br> Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-) </div></div> 1004376 1004380