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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.