Sub::Information 0.01

Ovid on 2007-05-02T08:57:43

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.


looks useful

markjugg on 2007-05-02T17:26:34

It looks useful-- thanks! Usually I just grep around if I want to find the package that a subroutine came from.

This looks like a helpful debugging tool.

Dunno...

jjore on 2007-05-02T19:32:26

I'm dubious. I suspect this just means your module is another part of the debugging toolchain that can go out of sync with perl or other parts of the toolchain that it depends on.

This is lots of introspection against perl and that's a moving target.

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.

"Information"

Alias on 2007-05-02T23:28:04

Shouldn't that be Sub::Inspector?

Of course, I wrote Class::Inspector and Module::Inspector, so there's some element of bias there :)

Re:"Information"

Aristotle on 2007-05-03T06:43:49

I agree, that’s a much better name. “Sub::Information” tells me nothing.

Thanks!

Shlomi Fish on 2007-05-03T04:25:02

Thanks for the module - keep up the good work.