in reply to 'extract' subs from source code
try this:
it works for me.use warnings; use strict; while(<ARGV>){ chomp; print $1,$/ if/^sub\s+?(.+?){/; ## print subroutine name if(/^sub\s+?/.. /^}/){ print $_,$/; } }
UPDATE:
The code above, is based on the assumption that:
- the OP's script(s) start every sub on a new line,
- the OP's script(s) and question does not cover anonymous subroutine
Please, it should also be noted that the above may not take care of all subroutrine declaration in perl script.... chomp; print $1, $/ if /^(?:.+)?\bsub\s+?(.+?){/; ## assumption still her +e if ( /^(.+)?\bsub\s+?(.+?)?{/s .. /^(.+)?}/s ) { ## anonymous sub + included print $_, $/; } ...
rovf thanks for the eagle eye ::)
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
In Section
Seekers of Perl Wisdom