Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

PadWalker::var_name BUG?

by LanX (Saint)
on Feb 16, 2016 at 17:51 UTC ( [id://1155372]=perlquestion: print w/replies, xml ) Need Help??

LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

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

    Read perlintern's section of Pad Data Structures. If I'm reading it correctly, eval does have a pad but it goes away when it is finished executing.

    Update: I'd play with it in the debugger if I had more time to spare.

      Thanks! :)

      Just ...

      > I'd play with it in the debugger if I had more time to spare.

      not sure what you mean, PadWalker is an XS module and the perldebugger doesn't help there.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

        I'm not sure why I said debugger either but yeah, I still haven't had time to muck with it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1155372]
Approved by Old_Gray_Bear
Front-paged by Tanktalus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found