I'm seeking enlightenment! This is about the Perl debugger and lexicals ('my' variables). Here's a script:
#! /usr/bin/perl -ws use mytest2; print mt2(55), "\n";
And here's the module it use's:
#! /usr/bin/perl -w package mytest2; require Exporter; our @ISA = qw( Exporter ); our @EXPORT = qw( mt2 ); my $a = 23; sub mt2 { my $b = $_[0] * 2; # return $a + $b; } 1;
My problem is this: With the return line in mt2() commented as shown, I run the top script via 'perl -d' and single-step to the first line of mt2() (that line hasn't executed yet). The debug command 'x $a' returns 'undef' - the debugger can't 'see' $a, even though it is declared earlier in the module file.
When the indicated line is uncommented, this isn't the case anymore -- the debugger reports the proper value of $a before the first line of mt2() is executed, even before it gets referenced or used (in the second line).
I can add code to reference the lexical vars in a module's subroutine that I can set a breakpoint in. But can I not access those lexicals directly? - anyway? - via the debugger?
In reply to Debugger and lexicals by lzipin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |