Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: how can I access code ref contents, not call it?

by autark (Friar)
on Jan 04, 2001 at 05:47 UTC ( [id://49668]=note: print w/replies, xml ) Need Help??


in reply to how can I access code ref contents, not call it?

With perl 5.6 you should be able to say:
use B::Deparse; sub bar { print "foo" } my $deparse = B::Deparse->new(); my $body = $dep->coderef2text(\&bar); print $body;
(See perldoc B::Deparse). This returns the coderef as plain text. Or you might use the B module via the O module to do some of the work yourself.

Autark.

Replies are listed 'Best First'.
Re (tilly) 2: how can I access code ref contents, not call it?
by tilly (Archbishop) on Jan 04, 2001 at 05:55 UTC
    If you try that, it is not reliable. In the case of closures there can be considerable context which you miss. Such as which variables are global and which are private lexicals, and in the latter case what are the values of said lexicals.

    There will be far fewer scoping games to cope with if you compile it yourself in a known scope.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://49668]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (None)
    As of 2024-04-25 00:00 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found