Sub::Inspector - get infomation from a subroutine reference
This document describes Sub::Inspector version 0.01.
use Sub::Inspector; # get file, line, name use File::Spec; my $code = File::Spec->can('canonpath'); my $inspector = Sub::Inspector->new($code); print $inspector->file; #=> '/Users/Cside/perl5/ ... /File/Spec/Unix.pm' print $inspector->line; #=> 71 print $inspector->name; #=> 'canonpath' # get prototype use Try::Tiny; my $inspector2 = Sub::Inspector->new(\&try); print $inspector2->proto; #=> '&;@' # get attributes use AnyEvent::Handle; my $code = AnyEvent::Handle->can('rbuf'); my $inspector3 = Sub::Inspector->new(\&try); print $inspector3->attrs; #=> ('lvalue')
This module enable to get metadata (prototype, attributes, method name, etc) from a coderef. We can get them by the buit-in module, B.pm. However, it is a bit difficult to memorize how to use it.
alias: prototype
alias: attributes
Hiroki Honda (Cside) <cside.story [at] gmail.com>
Copyright (c) Hiroki Honda.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Sub::Inspector, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sub::Inspector
CPAN shell
perl -MCPAN -e shell install Sub::Inspector
For more information on module installation, please visit the detailed CPAN module installation guide.