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


In reply to Re: Debugger and lexicals by lzipin
in thread Debugger and lexicals by lzipin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.