[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: [ID 20000123.003] [BUG our() 5.005_63] Lexical scoping problems.



On Sun, Jan 23, 2000 at 09:38:42PM -0800, Gurusamy Sarathy wrote:
> Of course it is; both $a's are aliases to the same global.  our doesn't
> automatically local()ize.  You need to explicitly spell that
> C<local our $a = "Inner"> if that's what you want.

Oh, then the docs in perlfunc are a little confusing.  I read:

               An our declares the listed variables to be valid
               globals within the enclosing block, file, or eval.
               That is, it has the same scoping rules as a "my"
               declaration, but does not create a local variable.

as basically, "it scopes just like a my() variable except you can
refer to it as a fully qualified variable"

Okay, so color me stupid, but why is our()'s lexical scoping
capabilities useful?  Just for 'strict vars' reasons?


PS I just realized I've been using $a in my examples and tests, I
probably should be using something else.


-- 

Michael G Schwern                                           schwern@pobox.com
                    http://www.pobox.com/~schwern
     /(?:(?:(1)[.-]?)?\(?(\d{3})\)?[.-]?)?(\d{3})[.-]?(\d{4})(x\d+)?/i


Follow-Ups from:
Pete Jordan <pjordan1@email.mot.com>
References to:
Michael G Schwern <schwern@pobox.com>
Gurusamy Sarathy <gsar@ActiveState.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]