Well, they say that good Perl programmers are lazy. Goody for the good ones. Fortunately, I guess that programmers like me must be lazy, too.
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
print STDERR "Scanning ...\n";
# find dependent things ... note 'scandeps' only considers modules.
# note: do not say "*.pm" here or you won't look in subdirs
# replace 'path_to_my_app_libs' with whatever is correct for you ...
my @output = qx{scandeps.pl /path_to_my_app_libs/*};
my @keepers;
# The output of interest is the module-name, found in single quotes
foreach (@output) {
chomp;
next unless /^'([A-Z].*?)'/;
push @keepers, $1;
}
print STDERR "Installing ...\n";
foreach (@keepers) {
# The output is a little "wordy."
# Omit hundreds o' things that we know are really parts of others.
next if /^Date::Manip::TZ::/;
next if /^Date::Manip::Offset::/;
qx{cpanm $_}; # install it
}
# see if we got everything ...
# (failure of some of these is not necessarily awful)
foreach (@keepers) {
print STDERR "require $_\n";
eval "require $_"; # magic necessary voodoo ... see 'perldo
+c require'
}
print "Normal completion.\n";
At first I was seriously flummoxed by the fact that I did not get complete results. It turns out that it is very important that the scandeps.pl command ends with “*” and not, as originally written, “*.pm” (The first form omits subdirectories.)
This script requires App::cpanminus (for cpanm) and Module::ScanDeps (for scandeps.pl).
As written, it still does not make any improvements to the order in which things are attempted. I took a brief look at the hashref returned by scan_deps() and it does look like it could be used more fully, i.e. in order to do that. (No doubt, it already has...)