in reply to confused about local $/ in perl debugger

I'm not a regular user of the perldebugger, but my understanding was that x worked from the package scope, not the lexical scope. If you wanted to dive down into the lexical scope, you needed y (and the PadWalker module). The debugger isn't terribly smart... hooked around the whole application, and thus outside the lexical scope in question. It's non-trivial to probe a lexical/local from outside their scope.

This appears true for my lexicals and locals. Try:

my $foo = 10; $bar = 10; sub somelocals { my $foo = 42; local $bar = 42; # "x $foo", "x $bar" are 10 here } somelocals();

Update:

This seems version dependent - my results and yours are consistent with v5.8.0. On v5.8.6, I see the opposite behaviour with x. (ie. lexicals are exposed as expected.)

re-Update:

Ignore. My testing was flawed.

Replies are listed 'Best First'.
Re^2: confused about local $/ in perl debugger
by lupey (Monk) on May 24, 2005 at 14:26 UTC
    Your reply further confuses me. When I run your script in the debugger, $foo and $bar inside the subroutine are 42. The address of $foo and $bar changes appropriately.

    In my OP, notice that the address of $/ changes appropriately but the value does not.

    I'm runnning Perl 5.8.6 on Cygwin if this makes a difference.

    lupey

      Yeah, and now I am confused too. I never should have offered debugger advice. I am seeing different results too. (on v5.8.0):

      # inside - main::changeRS DB<1> x $/ 0 undef DB<2> x \$/ 0 SCALAR(0xfab54) -> ' '

      I am seeing that the value changes if I evaluate at that point, but if I 'x' the reference I see a new location, but the old value.

      Also, I can now no longer reproduce my lexical oddness from before. I think that my one trial silently fell out of the inner scope. Even my local $bar example is behaving as both x \$bar and x $bar.

      Loath as I am to say this, (especially with my track record in this thread) I think that this is a bug in the debugger. I am going to test with other special vars...