You're looking for B::Deparse. In fact, you have the usage almost correct, except instead of printcode the method is called coderef2text.
use B::Deparse; sub somecode { do { print "some stuff\n" } } my $somevar = B::Deparse->new(); print $somevar->coderef2text(\&somecode);
However you might want to read the docs, as B::Deparse is still in development and contains some caveats.
In reply to Re: Printing the code of a coderef
by Trizor
in thread Printing the code of a coderef
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |