Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Identify and trim unused undeeded perl modules

by brycen (Monk)
on Jan 07, 2009 at 22:40 UTC ( #734753=perlquestion: print w/ replies, xml ) Need Help??
brycen has asked for the wisdom of the Perl Monks concerning the following question:

I'm working with a large legacy system with an install script that pulls in close to 200 perl modules. Now at least 25% and probably 50% of those are never used.

I can start by greping for all the "use" lines, then diff to see what I can trim. But is there a way to do better? To determine which pm's are in are "use'ed without actually getting used?

The goal here is to convert as many CPAN modules into supported Debian packages, by the way. And sometimes it's awkward to start with a use statement and end up with the proper Debian name.

Comment on Identify and trim unused undeeded perl modules
Re: Identify and trim unused undeeded perl modules
by kyle (Abbot) on Jan 07, 2009 at 22:48 UTC

    Maybe you could run the install script under Devel::Cover and see which code is actually used. You'd have to be careful, however, that you don't cut out code that gets used in some case that you're not exercising.

Re: Identify and trim unused undeeded perl modules
by CountZero (Bishop) on Jan 07, 2009 at 23:02 UTC
    Devel::Dependencies might be of assistance here.

    According to the docs it "uses a BEGIN and a CHECK block to find the changes in %INC".

    Of course, if a module is use-d but never actually used, it will still show up in %INC.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://734753]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-12-21 07:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (104 votes), past polls