perlquestion
cbrandtbuffalo
Is there a standard module or regex out there to search a file system and list all modules that are actually being used?
<p>We're preparing for a perl upgrade, and I want to avoid having to re-install modules that we no longer use. For example, we currently use DCE for authentication/authorization, so we have the DCE module. But we are moving off DCE, so we'll never need that module again.
<p>I started writing a simple script to look for 'use', 'require', 'do', etc. but there are enough permutations that it started to seem non-trivial. There are other tricky bits like DBI and the RootClass option that is like a use, or Class::DBI with the inflate option that can indicate a module to use.
<p>Anyone do this already?
<p><b>Update:</b> I'm starting to focus my problem based on the comments thus far.
<ol><li>I want to try to do this without running the actual code. Specifically, I'm going to run some script against our Perforce depot (version control repository) because I feel I can trust that if it's in a prod mode there, it's running somewhere in our environment. Plus I can run the script any time without involving a bunch of other support people.
<li>By default, this limits what I can look at. As mentioned in [id://445518] and other places, you can't detect modules when the module or method names are generated dynamically. I don't think we do this much.
<li>I'm only looking for CPAN modules used by programs, not necessarily in-house modules. The difference is our in-house modules are all supported and the support person should know if it's being used or not.
</ol>
<p>So I'm considering going ahead with what I started which is to work file-by-file and look for all the ways I know of to pull in a module (use, require, etc. see above). I'll create a test file that uses all of them and add test cases as they come up. I think I'll start with [cpan://Module::Info] as suggested below and just add cases to that.