I get tired of trying to remember all of the modules necessary to get information about subroutines, so I've released Sub::Information. This aggregates those modules under one roof and provides a clean interface. No modules are loaded until they're actually needed, thus keeping it fairly lean.
use Sub::Information; my $info = inspect(\&code); print $info->name; print $info->package; print $info->code; print $info->address; my $variables = $info->variables; while ( my ($var, $value) = each %$variables ) { print "$var = $value\n"; }
Comments, requests, and patches welcome. Read the docs for caveats and other features.
Re:Dunno...
Ovid on 2007-05-02T19:38:10
Yes, this module might be a bad idea, but I can never remember all of the other modules when I need them and I sling subroutines around enough that I need them. I find a lot of the code that I like or use are things that Perl 6 will give me for free. It's a frustrating wait.
Re:Dunno...
jjore on 2007-05-03T04:06:47
*shrug*
Fair enough.
Re:"Information"
Aristotle on 2007-05-03T06:43:49
I agree, that’s a much better name. “Sub::Information” tells me nothing.
Thanks for the module - keep up the good work.