Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
When is my variable not really mine?by gaspodethewonderdog (Monk) |
on Sep 07, 2000 at 17:34 UTC ( [id://31389]=perlquestion: print w/replies, xml ) | Need Help?? |
gaspodethewonderdog has asked for the wisdom of the Perl Monks concerning the following question:
Having read a lot of, coded a lot of and experienced a lot of other's poorly programmed code I thought I had a *very* clear understanding of the uses of globals, locals and mys in perl. Recently however I learned that either is not the case or somebody is doing something so bizarre to munge perl that I just don't want to know. I'm hoping the latter but guessing the former. The problem is that I am creating a 'my' variable within my own personal scope within the curly braces and somebody is twiddling with my data. I had always hoped this wouldn't happen but it has. I asked the engineer's solution and he said to change the variable's name to make sure there wasn't any name collisions in the lookup table. Hmmm... I thought constructs like my/local were supposed to prevent that? Silly me I guess. So now I am more than a little curious if there is a time when a variable declared with my really isn't getting new memory declared in the lookup table. I would go play with the code and try using local to see if replacing the variable on the stack changed the behavior of the program but this is production code and I'd rather not be the one hosing things, especially since there is no formal test environment other than production for this. I'm not looking for an explanation of how my works, but maybe I do because at a fundamental level the way I consider it works is wrong.
Back to
Seekers of Perl Wisdom
|
|