LanX has asked for the wisdom of the Perl Monks concerning the following question:
I found a serious limitation in PadWalker and I'm not optimistic this can be resolved easily.
var_name() seems to fail if the originating context of the lexical variable was a string eval
use strict; use warnings; use Data::Dump qw(pp dd); use PadWalker qw/var_name/; sub _ { return var_name(1, \$_[0] ) => $_[0] } sub t_ { _ my $xxx=666 } dd [ t_ ]; # works: ["\$xxx", 666] dd [ _ my $xxx=666 ]; # works: ["\$xxx", 666] dd [ eval '_ my $xxx=666' ]; # fails: [undef, 666]
The module is called PadWalker and seems eval doesn't use a "pad" for lexicals (?)
This limitation isn't listed in the docs (no mention of eval at all).
Or am I missing something?
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: PadWalker::var_name BUG?
by Mr. Muskrat (Canon) on Feb 16, 2016 at 18:45 UTC | |
by LanX (Saint) on Feb 17, 2016 at 17:45 UTC | |
by Mr. Muskrat (Canon) on Feb 17, 2016 at 19:00 UTC |