in reply to Re: Examples of Where "our" is really needed
in thread Examples fo Where "our" is really needed
The primary use of an our declaration is to hide the variable from the effects of a use strict "vars" declaration; since the variable is masquerading as a my variable, you are permitted to use the declared global variable without qualifying it with its package. However, just like the my variable, this only works within the lexical scope of the our declaration. In this respect, it differs from use vars, which affects the entire package and is not lexically scoped.
I am trying to think of some examples where this is a clear advantage. Either some tricks it makes work or ways it can be leveraged to make code cleaner. If all it was used for is declaring global variables then either declaring them up front with "my" or use vars would do. I figure there must be some higher reason for the "our" feature.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Examples of Where "our" is really needed
by Roy Johnson (Monsignor) on May 04, 2005 at 22:32 UTC |