Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Printing the code of a coderef

by belden (Friar)
on Jun 28, 2007 at 15:08 UTC ( [id://623911]=note: print w/replies, xml ) Need Help??


in reply to Printing the code of a coderef

You can also try using Data::Dumper... just set $Data::Dumper::Deparse to true.
use Data::Dumper; $Data::Dumper::Deparse = 1; my $code = sub { print "hello world\n" }; print Dumper $code; __END__ $VAR1 = sub { print "hello world\n"; };
A more interesting example:
{ package foo; use strict; sub get_coderef { sub { print "hello world\n" } } } use Data::Dumper; $Data::Dumper::Deparse = 1; print Dumper(foo->get_coderef); __END__ $VAR1 = sub { package foo; use strict 'refs'; print "hello world\n"; };

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-20 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found