Install perl modules in bulk with some logic to make this more efficient.
-
get a portable Windows-Perl from Strawberry
-
open Perl-Location with
portableshell.bat
-
update all current (base) modules
cmd.exe /c cpanm App::cpanoutdated cmd.exe /c cpan-outdated -p cmd.exe /c cpan-outdated -p | cpanm
-
install required modules
cmd.exe /c cpanm Carp Carp::Always Data::Dumper
-
run bulk-installer to add all wanted modules
perl InstallCpanModules.pl [ --only-updates | --no-updates ] filepath perl InstallCpanModules.pl test-module-lists/SmallModuleExample.txt
-
have a portable Windows-Perl with all wanted modules :)
One problem with cpanm is that it don't save/cache a failed installation state. If a module needs a module which was already tried cpanm will try it again If you install many modules, and not all are working correctly it will waste much time, and the installation of modules is already not fast :(
So the main enhancement of this script should be this cache of failed or not-found dependencies to speed up a bootstrap installation of many modules.
For every external process call (perl/cpanm) there will be a logfile in the log-subfolder with the call information, start/end time, exitcode and the complete output.
Logfiles:
DATE
_TIME
_perl_detail_info.log- Perl-System-Information
perl -V
- Perl-System-Information
DATE
_TIME
_installed_modules_found.log- Perl-Modules found via
cpan -l
- Perl-Modules found via
DATE
_TIME
_modules_to_install_from_file.log- Modules listed in the given file to install.
DATE
_TIME
_modules_install_already.log- Modules from file already installed.
DATE
_TIME
_modules_need_to_install.log- Modules from files needs to be installed.
DATE
_TIME
_modules_to_install_with_deps_extended.log- analyze result - modules need to install/update with their direct dependencies.
DATE
_TIME
_modules_with_available_updates.log- list of modules with an update available, analyzed by
cpan-outdated --exclude-core -p
- list of modules with an update available, analyzed by
DATE
_TIME
_modules_install_not_found.log- list of modules which are not found, via cpan.
DATE
_TIME
_modules_install_failed.log- list of modules where the installation failed.
DATE
_TIME
_fetch_dependency__MODULENAME
.log- output of list dependency call
cpanm --no-interactive --showdeps MODULENAME
- output of list dependency call
DATE
_TIME
_install_module__MODULENAME
__install|update
-success|failed|failed-start
.log- output of install/update call. Type and result are in filename.
- Installed via
cpanm --verbose --no-interactive MODULENAME
Script process:
- import module list - if not update-only
- check installed modules
- search for installed modules
- search for missing dependency modules
- search for available update of installed modules - if not no-updates
- now the installation loop
- get the next module which has no found dependency, or abort of there is none.
- re-check dependencies - but there should be noting.
- try to install module
- if ok remove this module from the dependency list of each module, if listed
- if not ok mark all modules which depend on this als failed, and all which depend on them - and so on - recursion
- mark this module als installed or failed.
- repeat loop
Please report bugs on GitHub.
The source code repository can be found at https://github.com/mardem1/perl-bulk-module-installer
Markus Demml, mardem@cpan.com
Copyright (c) 2025, Markus Demml
This library is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. The full text of this license can be found in the LICENSE file included with this module.
This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.