http://qs321.pair.com?node_id=623402


in reply to Printing the code of a coderef

A very recent module which can help you with this is Sub::Information. To tell the truth, it uses B::Deparse (via Data::Dump::Streamer) to get the source code, but its rationale is to bring together a bunch of modules which collect information about code and offer a nice integrated API.

sub somecode { do { print "some stuff\n" } } use Sub::Information as => 'inspect'; my $code_info = inspect(\&somecode); print $code_info->code;