Does anyone have any suggestions for a good approach to finding all the CPAN dependencies that might have arisen in a bespoke development project. As tends to be the case your local development environment rarely matches your live one and as you build more and more projects you tend to build up a local library of installed modules. These then lead to you not necessarily noticing that your latest project has a requirement on a non-core module. As there is generally a requirement to package the entire project up for deployment to another group (in our case our operations team), it is important to know what modules should be included in the package.
Does anyone have any insights into the problem.
Thanks
Peter
I've had this problem myself. Devel::Modlist (as suggested by this answer) takes a dynamic approach. It reports the modules that were actually loaded during a particular run of your script. This catches modules that are loaded by any means, but it may not catch conditional requirements. That is, if you have code like this:
and
$some_condition
happens to be false,Devel::Modlist
will not listSome::Module
as a requirement.I decided to use Module::ExtractUse instead. It does a static analysis, which means that it will always catch
Some::Module
in the above example. On the other hand, it can't do anything about code like:Of course, you could use both approaches and then combine the two lists.
Anyway, here's the solution I came up with:
You'd run this like:
It prints a list of all non-core modules necessary to run the scripts listed. (Unless they do fancy tricks with module loading that prevent Module::ExtractUse from seeing them.)
Here is a quickie bash function (using the excellent ack):