use Dependencies::Searcher; my $searcher = Dependencies::Searcher->new(); my @elements = $searcher->get_files(); my @uses = $searcher->get_modules($path, "use"); my @uniq_modules = $searcher->uniq(@uses); $searcher->dissociate(@uniq_modules); $searcher->generate_report($searcher->non_core_modules); # Prints to cpanfile requires 'Module::Name', '0.32'; requires 'Module::Name::Foo', '0.000017'; requires 'Module::Name::Bar', '1.15'; ...
Description and why this module ?
Maybe you don't want to have to list all the dependencies of your Perl application by hand and want an automated way to build it. Maybe you forgot to do it for a long time ago. Or just during a short period.
Anyway, you've add lots of CPAN modules. Carton is here to help you manage dependencies between your development environment and production, but how to keep track of the list of modules you will pass to Carton?
Event if it is a no brainer to keep track of this list by adding it by hand, it can be much better not to have to do it.
You will need a tool that will check for any
use in your module package, and report it into a formated file that could be used as an input Carton
cpanfile. Any duplicated entry will be removed and modules versions will be checked and made available. Core modules will be ommited because you don't need to install them (except in some special case).
This project has begun because it has happened to me, and I don't want to search for modules to install by hand, I just want to run a simple script that update the list in a convenient way. It was much more longer to write the module than to search by hand so I wish it could be useful for you now.
This module is made to search dependencies for installed distributions, it is not supposed to manage anything else.
Why isn't it just yet another Module::Scandeps ?
Module::ScanDeps is a bi-dimentional recursive scanner: it features dependencies and directories recursivity.
Dependencies::Searcher only found direct dependencies, not dependencies of dependencies, it scans recursively directories but not dependencies..
These direct dependencies are passed to the Perl toolchain (cpanminus, Carton) that will take care of any recursive dependencies.