Keep It Simple, Stupid | |
PerlMonks |
Re^5: Global vs. local?by Corion (Patriarch) |
on May 28, 2009 at 12:10 UTC ( [id://766638]=note: print w/replies, xml ) | Need Help?? |
You are not using strict, which would have enforced proper declaration of your lexical variables as lexicals:
Here, $j is a global variable, which use strict; would tell you about. You need to write this as:
so that each subroutine gets its own copy of $j instead of them all using the one, shared $j. strict also has the convenient feature of alerting you to mistyped variable names, which is why I recommend to use it always.
In Section
Seekers of Perl Wisdom
|
|