stmullins has asked for the wisdom of the Perl Monks concerning the following question:
Our utilities use a lot of in-house modules, and it's routine for developers to simply paste in a long list of 'use modX;' statements without checking whether or not the module is actually needed. This is the case not only for utilities, but for the modules themselves. Or, if a subroutine is no longer used in file, the use statement that pulled it in isn't updated or removed. The result is that we've accumulated a lot of unused functionality, and can't identify what we don't need. I'd like to figure out which subroutines in an imported module are actually used, so we can clean up or consolidate our libraries. I could also build a map of our entire repository of utilities and modules and give awards to those subroutines/modules that are frequently referenced ... :)
A couple of considerations:
There are two approaches I've considered:
cat <utility|module> begin.pl | perl -cwhere begin.pl is something like:
BEGIN { print "$_=$main::{$_}\n" foreach grep(*{$main::{$_}}{CODE}, sort keys %main::); }
This does list all of the code symbols defined in the utility ... and, unfortunately, those defined in any imported
modules, all listed as if belonging to main::. I'm not sure how to distinguish the imported symbols from those
defined in the target file.
Note that begin.pl is actually more complicated than the above because I want to harvest module locations from %INC,
and potentially look at the module symbol tables as well.
Any ideas?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Identify subs and their source
by Khen1950fx (Canon) on May 25, 2011 at 07:30 UTC | |
Re: Identify subs and their source
by davido (Cardinal) on May 24, 2011 at 23:58 UTC | |
Re: Identify subs and their source
by TomDLux (Vicar) on May 24, 2011 at 23:25 UTC | |
Re: Identify subs and their source
by John M. Dlugosz (Monsignor) on May 24, 2011 at 22:14 UTC |