On 8/24/07, Paul Lalli <[EMAIL PROTECTED]> wrote:
snip
> 'our', like 'my', is lexically scoped.  Its effects are terminated
> when the innermost enclosing block ends.  So if you're using the same
> package variable in two different blocks, you have to use 'our' in
> each of them:
snip
> Your syntax for 'our' is confusing at best.  Just declare it once, at
> the very top of your program.
snip
> Again.  Stop using 'our' all over the place.  Declare your variables
> once, at the beginning of your program, if it's being used throughout
> the program.
snip

I can't say that I agree with the advice to declare all of your our
variables once at the top of your program.  To my way of thinking this
defeats the purpose of having the our function*.  I have a
once-per-function rule for our; if a function needs to use a global
variable, then it has to request it.  This means that when you come
back to the code a year later, and are looking at just that one
function, you can easily see that the variable is special (i.e. used
by many functions).  That said, the code you were referring to was
definitely overusing our.  It doesn't need to be attached to every
reference to the variable.

* yes, the variable is still visible to all packages in the same file
without having to be fully qualified, but I consider that aspect of
our a misfeature.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to