• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/Sub/H03-May-2022-18447

t/H24-Dec-2016-121103

ChangesH A D24-Dec-2016179 84

LICENSEH A D24-Dec-201617.9 KiB380292

MANIFESTH A D24-Dec-2016187 1312

META.jsonH A D24-Dec-20161.2 KiB5553

META.ymlH A D24-Dec-2016665 2625

Makefile.PLH A D24-Dec-20161.1 KiB5241

READMEH A D24-Dec-20162.5 KiB10261

README.mdH A D24-Dec-20162.6 KiB9660

cpanfileH A D24-Dec-2016307 1713

README

1NAME
2
3    Sub::Info - Tool for inspecting subroutines.
4
5DESCRIPTION
6
7    Tool to inspect subroutines.
8
9EXPORTS
10
11    All exports are optional, you must specify subs to import.
12
13    my $hr = sub_info(\&code)
14
15    my $hr = sub_info(\&code, @line_numbers)
16
17      This returns a hashref with information about the sub:
18
19          {
20              ref        => \&code,
21              cobj       => $cobj,
22              name       => "Some::Mod::code",
23              file       => "Some/Mod.pm",
24              package    => "Some::Mod",
25
26              # Note: These have been adjusted based on guesswork.
27              start_line => 22,
28              end_line   => 42,
29              lines      => [22, 42],
30
31              # Not a bug, these lines are different!
32              all_lines  => [23, 25, ..., 39, 41],
33          };
34
35      $info->{ref} => \&code
36
37	This is the original sub passed to sub_info().
38
39      $info->{cobj} => $cobj
40
41	This is the c-object representation of the coderef.
42
43      $info->{name} => "Some::Mod::code"
44
45	This is the name of the coderef. For anonymous coderefs this may
46	end with '__ANON__'. Also note that the package 'main' is special,
47	and 'main::' may be omitted.
48
49      $info->{file} => "Some/Mod.pm"
50
51	The file in which the sub was defined.
52
53      $info->{package} => "Some::Mod"
54
55	The package in which the sub was defined.
56
57      $info->{start_line} => 22
58
59      $info->{end_line} => 42
60
61      $info->{lines} => [22, 42]
62
63	These three fields are the adjusted start line, end line, and array
64	with both. It is important to note that these lines have been
65	adjusted and may not be accurate.
66
67	The lines are obtained by walking the ops. As such, the first line
68	is the line of the first statement, and the last line is the line
69	of the last statement. This means that in multi-line subs the lines
70	are usually off by 1. The lines in these keys will be adjusted for
71	you if it detects a multi-line sub.
72
73      $info->{all_lines} => [23, 25, ..., 39, 41]
74
75	This is an array with the lines of every statement in the sub.
76	Unlike the other line fields, these have not been adjusted for you.
77
78SOURCE
79
80    The source code repository for Sub-Info can be found at
81    http://github.com/exodist/Sub-Info/.
82
83MAINTAINERS
84
85    Chad Granum <exodist@cpan.org>
86
87AUTHORS
88
89    Chad Granum <exodist@cpan.org>
90
91    Kent Fredric <kentnl@cpan.org>
92
93COPYRIGHT
94
95    Copyright 2016 Chad Granum <exodist@cpan.org>.
96
97    This program is free software; you can redistribute it and/or modify it
98    under the same terms as Perl itself.
99
100    See http://dev.perl.org/licenses/
101
102

README.md

1# NAME
2
3Sub::Info - Tool for inspecting subroutines.
4
5# DESCRIPTION
6
7Tool to inspect subroutines.
8
9# EXPORTS
10
11All exports are optional, you must specify subs to import.
12
13- my $hr = sub\_info(\\&code)
14- my $hr = sub\_info(\\&code, @line\_numbers)
15
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
36        This is the original sub passed to `sub_info()`.
37
38    - $info->{cobj} => $cobj
39
40        This is the c-object representation of the coderef.
41
42    - $info->{name} => "Some::Mod::code"
43
44        This is the name of the coderef. For anonymous coderefs this may end with
45        `'__ANON__'`. Also note that the package 'main' is special, and 'main::' may
46        be omitted.
47
48    - $info->{file} => "Some/Mod.pm"
49
50        The file in which the sub was defined.
51
52    - $info->{package} => "Some::Mod"
53
54        The package in which the sub was defined.
55
56    - $info->{start\_line} => 22
57    - $info->{end\_line} => 42
58    - $info->{lines} => \[22, 42\]
59
60        These three fields are the _adjusted_ start line, end line, and array with both.
61        It is important to note that these lines have been adjusted and may not be
62        accurate.
63
64        The lines are obtained by walking the ops. As such, the first line is the line
65        of the first statement, and the last line is the line of the last statement.
66        This means that in multi-line subs the lines are usually off by 1.  The lines
67        in these keys will be adjusted for you if it detects a multi-line sub.
68
69    - $info->{all\_lines} => \[23, 25, ..., 39, 41\]
70
71        This is an array with the lines of every statement in the sub. Unlike the other
72        line fields, these have not been adjusted for you.
73
74# SOURCE
75
76The source code repository for Sub-Info can be found at
77`http://github.com/exodist/Sub-Info/`.
78
79# MAINTAINERS
80
81- Chad Granum <exodist@cpan.org>
82
83# AUTHORS
84
85- Chad Granum <exodist@cpan.org>
86- Kent Fredric <kentnl@cpan.org>
87
88# COPYRIGHT
89
90Copyright 2016 Chad Granum <exodist@cpan.org>.
91
92This program is free software; you can redistribute it and/or
93modify it under the same terms as Perl itself.
94
95See `http://dev.perl.org/licenses/`
96