in reply to Re^3: standard perl module and BEGIN block.
in thread standard perl module and BEGIN block.
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: standard perl module and BEGIN block.
by eric256 (Parson) on Aug 17, 2004 at 06:35 UTC | |
by BrowserUk (Patriarch) on Aug 17, 2004 at 10:55 UTC | |
|
Re^5: standard perl module and BEGIN block.
by ikegami (Patriarch) on Jun 12, 2010 at 19:00 UTC | |
|
Re^5: standard perl module and BEGIN block. (declaring vs. using globals)
by tye (Sage) on Jun 12, 2010 at 16:53 UTC | |
by BrowserUk (Patriarch) on Jun 12, 2010 at 17:31 UTC |