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

Re^2: Lexical pad / attribute confusion

by adrianh (Chancellor)
on Dec 21, 2002 at 23:58 UTC ( [id://221687]=note: print w/replies, xml ) Need Help??


in reply to Re: Lexical pad / attribute confusion
in thread Lexical pad / attribute confusion

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?

Replies are listed 'Best First'.
Re: Re^2: Lexical pad / attribute confusion
by shotgunefx (Parson) on Dec 22, 2002 at 00:00 UTC
    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
        Actually I get different results. On 5.6.1 (win32) lexicals declared after INIT are not visible from INIT.
        #!/usr/bin/perl use warnings; use strict; INIT { use Data::Dumper; use PadWalker qw (peek_my peek_sub); print Dumper(peek_my(0)); } my $foo = 'lee'; my $bar = "Bar"; { my @foo = (1..3); } { my @bar = (9..12); } print Dumper(peek_my(0)) __END___ $VAR1 = {}; $VAR1 = { '$foo '$bar };
        my has both runtime and compile time effects, I wouldn't be suprised if they are on the same pad, but are removed from the padlist when the block is exited.

        -Lee

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-04-18 14:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found