Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Lexical pad / attribute confusion

by djantzen (Priest)
on Dec 21, 2002 at 23:48 UTC ( [id://221686]=note: print w/replies, xml ) Need Help??


in reply to Lexical pad / attribute confusion

If my understanding of Elian's explanations in Perl Internals - references and symbol table is correct, the reason is because %foo and %bar are just bare blocks, and as such do not get their own pads. Rather, they share the pad of the enclosing sub, which is that of the package, and therefore the INIT block can see them as well when peek_my inspects the package's pad.

Replies are listed 'Best First'.
Re^2: Lexical pad / attribute confusion
by adrianh (Chancellor) on Dec 21, 2002 at 23:58 UTC

    Hmm. Okay. What Elian said makes sense, but it leads to a new question.

    If %foo amd %bar are in the same pad, just finagled into different slots, why can't that last call to dump_lex see them?

      Because they are declared after dump_lex.

      -Lee

      "To be civilized is to deny one's nature."

        They're also declared after INIT, and you can see them from there ;-) Also, moving dump_lex after the declarations like this:

        Still gives you this (under 5.8):

        when init top-level pad is HASH(0x22e150) -> $%bar = \{}; HASH(0xb5b50) -> $%foo = \{}; when setting Attr in Foo for HASH(0xb5b50) top-level pad is when setting Attr in Bar for HASH(0x22e150) top-level pad is HASH(0x22e150) -> $%bar = \{}; when runtime top-level pad is

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://221686]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-24 02:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found