Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Lexical pad / attribute confusion

by diotalevi (Canon)
on Dec 23, 2002 at 12:11 UTC ( [id://221842]=note: print w/replies, xml ) Need Help??


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

As near as I can gather - it's just an innermost scope. I took the trouble to write a quickie XS library (Devel::DebugScope) to dump some of the scoping variables. You can download it here if you like: http://198.144.10.226/perl/Devel-DebugScope-0.01.tgz. I used it to instrument your code and it corroborates that CHECK and friends have an apparent lexical scope equivalent (or greater for BEGIN) than the inner scope. The key values to look at are scopestack_ix and savestack_ix (I guess).

use strict; use warnings; use PadWalker qw(peek_my); use Devel::DebugScope qw(dump_scope); CHECK { print "CHECK\n"; Devel::DebugScope::dump_scope(); print "\n\n"; } CHECK { peek_my(1)->{'%foo'}->{answer} = 42 }; print "Runtime outer\n"; Devel::DebugScope::dump_scope(); print "\n\n"; { my %foo; print $foo{answer}, "\n"; print "Runtime inner\n"; Devel::DebugScope::dump_scope(); print "\n\n"; }; __DATA__ CHECK scopestack_ix: 5 savestack_ix: 21 Runtime outer scopestack_ix: 3 savestack_ix: 10 42 Runtime inner scopestack_ix: 5 savestack_ix: 15

Fun Fun Fun in the Fluffy Chair

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

    ++. An excellent demonstration of what is happening.

    Now if only somebody can tell me why :-)

    (or point to the relevant docs if there are any).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-19 20:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found