in reply to Re^3: local our?
in thread local our?

Sorry, I didn't fully qualify that question. I was interested in how the perl compiler/runtime implements the our directive (if anyone here happens to know that).

Replies are listed 'Best First'.
Re^5: local our?
by Errto (Vicar) on Apr 07, 2006 at 04:08 UTC

    I'm not an internals guy, but I think loosely speaking what the compiler does is create a glob entry for that variable name in the current package's symbol table. This way, even when strict is in effect, the compiler can verify that that variable name, used unqualified, is valid because that name exists in the symbol table (after it checks that there's no lexical with that name in the pad).

    Actually it has to do a little more than that, because the scope of the our declaration is lexical; that is, you can do this:

    package A; our $foo; package B; print $foo;
    and it will still be referring to $A::foo. Not sure how it handles that.