in reply to Debugger and lexicals
Monks, I appreciate the variety of comments. In response, I made some variants to my test code.
In mytest2.pm, add a second subroutine below the first:
sub mt3 { return $a + 19; }
There's no call to mt3() in the top-level script. Nonetheless, the interpreter doesn't know that (I don't think), and shouldn't make $a disappear. But adding the additional sub definition doesn't change the outcome: the debugger still doesn't see $a inside mt2() (with the commented line in place).
Change #2: our $a; instead of my $a; . Now, the debugger sees $a on the first line of mt2() , whether or not there's a mt3() defined.
Surely it's a matter of $a being a lexical. But the debugger knows about 'global' lexicals if they're used in a function in which the debugger has stopped, and doesn't if they're not used there -- even when the lexicals are available to the whole module (well, from definition to EOF).
I don't know enough about the debugger to know if this is by design, or I haven't set a switch or option, or other operator error. Is this where PadWalker comes in?
-- Lee
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Debugger and lexicals
by dave_the_m (Monsignor) on Aug 08, 2011 at 13:28 UTC |