If unexpected changes are occurring to it, you will want to find where it is being changed. You will have little choice but to step through the code line by line in the debugger to find the offending code. This can be tedious.
And the really great thing with this approach is that if you have some errant code that is setting $var to some wacky value, or incrementing it when you don't expect it, all you have to do is to hang a breakpoint off the name of the sub in the debugger, and then just let it run at full clip until the routine gets called. Much less tedious.
By tie()ing the global variable you can add the same functionality and get the same benefit that of a subroutine wrapper in your examples. Then you even get compile-time spelling checks. ;-)
Read argumentation in its context!
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||