in reply to Re: How do I detect what modules are not being used?
in thread How do I detect what modules are not being used?

adamk,
If the name of the module never appears anywhere else in the file, then it's almost certainly not used

I assume you are thinking that if I do:

use CGI; my $q = CGI->new();
Then you will be able to tell if I have actually used that module? A huge portion of modules are not OO and export functions that do not need the module name to be invoked. Additionally, the module may be exporting constants.

The best this method can do is attempt to confirm actual use. Even then it is subject to break since the module name may appear in comments or code as false positive. Even reducing the comments and POD with perl -MO=Deparse will not be fool proof. Your method will not be a good indicator of modules not actually being used and will be a poor indicator of modules that are being used.

Cheers - L~R

Replies are listed 'Best First'.
Re^3: How do I detect what modules are not being used?
by adamk (Chaplain) on Apr 08, 2005 at 02:44 UTC
    I certainly don't consider it a complete method for handling all cases, but modification of large groups of modules tends to go like this. Run some wide scans, fix the obvious cases, and then work your way down the curve of diminishing returns.

    A minor change to check for the use statement having params, or the module being called having an @EXPORT (compulsory export) would largely resolve your issues.

    The poster is not going to automagically modify the files, he's just looking for clues. If a report can identify the 25-75% of obvious cases, then it's a good high yield starting point.