rockyb has asked for the wisdom of the Perl Monks concerning the following question:
I'd like to get the start and end ranges of subroutines in a file much the same way that Perl does for the %DB:sub hash when debugging is turned on.
I can approximate this using B:Utils::all_starts by looking for minimum and maximum COP lines, but that really isn't the same thing since the first executable line might not be on the same line as the sub declaration. For example:
sub five {
5;
}
sub six { 6; }
Note that the start and end lines of five() are one less and one greater than the single returned expression, 5; For six() though everything is on the same line.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to get line ranges of subroutines from Perl source code
by Your Mother (Archbishop) on Apr 16, 2014 at 19:50 UTC | |
by rockyb (Scribe) on Apr 17, 2014 at 01:36 UTC | |
by stevieb (Canon) on Jul 15, 2015 at 15:49 UTC | |
|
Re: How to get line ranges of subroutines from Perl source code
by LanX (Saint) on Apr 16, 2014 at 06:34 UTC | |
|
Re: How to get line ranges of subroutines from Perl source code
by karlgoethebier (Abbot) on Apr 16, 2014 at 18:58 UTC | |
by Anonymous Monk on Apr 16, 2014 at 20:07 UTC | |
by rockyb (Scribe) on Apr 17, 2014 at 01:56 UTC | |
by rockyb (Scribe) on Apr 17, 2014 at 09:30 UTC |