in reply to Re^12: the "our" declaration ?!! (special vars)
in thread the "our" declaration ?!!
The real benefit of "our" is that it's block scoped. It's not "I know about this variable in the current package, let me access it directly wherever I am". It's rather "Excuse me? I'd like to access this 'global' variable over here without having to prepend the package name." Its effects are much more restricted (OK, this depends on the location of the "our" declaration). So you specifically CAN'T declare something in one file and have it affect the code in another, you can't declare somewhere that you intend to use a 'global' variable and silence all fatal errors for such named variables all over the place no matter whether on that other place you are aware of some global.
Of course if you declare all your globals on top of the file it doesn't matter much whether you use vars ... or our (...). But that's about as clever as declaring all variables with my (...) on top of the file. You can, but you should not.
I would rather our in this block and our in that block and stay "safe" elsewhere.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^14: the "our" declaration ?!! (special vars)
by tilly (Archbishop) on Jan 21, 2009 at 23:38 UTC | |
by LanX (Saint) on Jan 22, 2009 at 04:44 UTC | |
by tilly (Archbishop) on Jan 22, 2009 at 05:26 UTC | |
by Anonymous Monk on Jan 22, 2009 at 07:21 UTC | |
by LanX (Saint) on Jan 22, 2009 at 13:09 UTC | |
by tilly (Archbishop) on Jan 22, 2009 at 14:58 UTC |