Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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

Replies are listed 'Best First'.
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.


    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?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2022-12-01 07:04 GMT
Find Nodes?
    Voting Booth?