in reply to How to combine multiple perl modules to make them run from command line

If you have CPAN and the appropriate permissions, then you could easily use a script to install from the command line. For example, using CGI:
#!/usr/bin/perl use strict; use warnings; use CPAN; CPAN::Shell->install('CGI');
Now, let's say you want to install all the dependencies. Cool, but the major dependencies are mostly core and/or dual-lived. You can't install or upgrade core dependencies without reinstalling perl, so you'll need to scratch the core modules off your list. The dual-lived modules can be upgraded, so leave them on the list. Add to that list any noncore dependencies that are there, and the script is done.

How do you find the dependencies? An easy way is to use CPAN::FindDependencies. Download it, then run this script to get a record:

#!/usr/bin/perl use strict; use warnings; use CPAN; open STDOUT, '>', '/root/Desktop/CGIdeps'; system("cpandeps CGI"); close STDOUT;
You can also run cpandeps CGI from the command line.

Next, to determine which modules are core, you want to use Module::CoreList. From the command line, do corelist CGI. It'll tell you that it's core.

Is CGI core only or dual-lived? Use App::DualLivedList. From the command line, do dual-lived CGI. It'll tell you if it's dual-lived.

The finished script should look something like this:

#!/usr/bin/perl use strict; use warnings; use CPAN; CPAN::Shell->install( "FCGI", "Scalar::Util", "File::Spec", "Test::Harness", "Test::More", "CGI");

Replies are listed 'Best First'.
Re^2: How to combine multiple perl modules to make them run from command line
by DrHyde (Prior) on Nov 11, 2010 at 11:09 UTC

    What's in core varies from one version of perl to another, so unless you also nail down *exactly* what version of perl your application is for, then you may need to be a bit clever about core modules. But only a bit clever, cos it's pretty easy really.

    For every module that you depend on, including core modules, check to see if a recent enough version of it is installed. If not, add it to the list of modules that you need to install. Many core modules (at least of those which haven't been in core since forever) are dual-lived so also exist independently on the CPAN.

    Your script will end up looking something like this ...

    #!/usr/bin/perl use strict; use warnings; use CPAN; my %needed = ( Some::Module => 1.23, # must have at least version 1.23 Other::Module => 0, # any old version will do ... ); my @need_to_install = (); foreach my $module (keys %needed) { eval "use $module;"; if($@ || eval "${module}::VERSION < $needed{$module}") { push @need_to_install, $module; next; } } CPAN::Shell->install(@need_to_install);