Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re^4: standard perl module and BEGIN block.by BrowserUk (Patriarch) |
on Aug 16, 2004 at 21:47 UTC ( [id://383469]=note: print w/replies, xml ) | Need Help?? |
My thinking that a comment in the boiler plate code would be appropriate as once code gets into a module, those coming along after may not appreciate it's source or significance. Avoiding globals all together would be the best route, but that's not currently possible for the likes of these "special variables". For a long time I didn't really appreciate your concerns regarding our, but having quite recently been bitten by a typo in an our var, they can indeed cause mysterious problems. I guess what I would really like, whilst doing away with globals completely is not an option, would be a combination of the two; use vars; and our. The former would indicate those globals I intended to use and disable the warnings/strictures on them--but only within those scopes where I had used our for that same variable. Using our for a var that hadn't previously been declared with use vars would raise an error. As would attempting to use a global mentioned in use vars, without also having scoped it using our. I'm not really a S&M type, and that does sound like "belt & braces" even to me, but given my propensity for typos, and the number of saves that "Global symbol "$x" requires explicit package name.." makes on my behalf, I would welcome this ability.
In Section
Seekers of Perl Wisdom
|
|