Subject: | Pad walker work incorrect if eval frames occur |
Despite on DOC states:
Show quoted text
>The LEVEL argument is interpreted just like the argument to caller. So peek_my(0) returns a reference to a hash of all the my variables that are currently in scope; peek_my(1) returns a reference to a hash of all the my variables that are in scope at the point where the current sub was called, and so on.
But this is not true if there is 'eval' in callstack.
How to reproduce:
use PadWalker;
sub t{
$i = 0;
print "$i: @frames[0..3]\n" while @frames= caller($i++);
my $vars = PadWalker::peek_my( $i -1 );
print "MY: ", join( ', ', sort keys %$vars ), "\n";
}
my $x;
t();
eval{ t() };
OUTPUT:
1: main t.pl 14 main::t
MY: $x
1: main t.pl 15 main::t
2: main t.pl 15 (eval)
EXPECTED:
1: main t.pl 14 main::t
MY: $x
1: main t.pl 15 main::t
2: main t.pl 15 (eval)
MY: $x