1Sub::Info(3)          User Contributed Perl Documentation         Sub::Info(3)
2
3
4

NAME

6       Sub::Info - Tool for inspecting subroutines.
7

DESCRIPTION

9       Tool to inspect subroutines.
10

EXPORTS

12       All exports are optional, you must specify subs to import.
13
14       my $hr = sub_info(\&code)
15       my $hr = sub_info(\&code, @line_numbers)
16           This returns a hashref with information about the sub:
17
18               {
19                   ref        => \&code,
20                   cobj       => $cobj,
21                   name       => "Some::Mod::code",
22                   file       => "Some/Mod.pm",
23                   package    => "Some::Mod",
24
25                   # Note: These have been adjusted based on guesswork.
26                   start_line => 22,
27                   end_line   => 42,
28                   lines      => [22, 42],
29
30                   # Not a bug, these lines are different!
31                   all_lines  => [23, 25, ..., 39, 41],
32               };
33
34           $info->{ref} => \&code
35               This is the original sub passed to "sub_info()".
36
37           $info->{cobj} => $cobj
38               This is the c-object representation of the coderef.
39
40           $info->{name} => "Some::Mod::code"
41               This is the name of the coderef. For anonymous coderefs this
42               may end with '__ANON__'. Also note that the package 'main' is
43               special, and 'main::' may be omitted.
44
45           $info->{file} => "Some/Mod.pm"
46               The file in which the sub was defined.
47
48           $info->{package} => "Some::Mod"
49               The package in which the sub was defined.
50
51           $info->{start_line} => 22
52           $info->{end_line} => 42
53           $info->{lines} => [22, 42]
54               These three fields are the adjusted start line, end line, and
55               array with both.  It is important to note that these lines have
56               been adjusted and may not be accurate.
57
58               The lines are obtained by walking the ops. As such, the first
59               line is the line of the first statement, and the last line is
60               the line of the last statement.  This means that in multi-line
61               subs the lines are usually off by 1.  The lines in these keys
62               will be adjusted for you if it detects a multi-line sub.
63
64           $info->{all_lines} => [23, 25, ..., 39, 41]
65               This is an array with the lines of every statement in the sub.
66               Unlike the other line fields, these have not been adjusted for
67               you.
68

SOURCE

70       The source code repository for Sub-Info can be found at
71       http://github.com/exodist/Sub-Info/.
72

MAINTAINERS

74       Chad Granum <exodist@cpan.org>
75

AUTHORS

77       Chad Granum <exodist@cpan.org>
78       Kent Fredric <kentnl@cpan.org>
79
81       Copyright 2016 Chad Granum <exodist@cpan.org>.
82
83       This program is free software; you can redistribute it and/or modify it
84       under the same terms as Perl itself.
85
86       See http://dev.perl.org/licenses/
87
88
89
90perl v5.32.0                      2020-07-28                      Sub::Info(3)
Impressum