Skip to content

Reinstall All Modules On New Perl

Kang-min Liu edited this page Oct 23, 2020 · 5 revisions

How To Reinstall All Modules On New Perl

Sometimes when you install a new perl version, you want to put all the modules you were using on a previous version onto your new perl install.

You can easily get the list of modules in the current perl installation with list-modules command:

perlbrew use perl-5.8.8@foo-project
perlbrew list-modules

That simply prints out module names that you can use latter.

Since perlbrew 0.81, it is possible to use the clone-modules command to reinstall all the modules from a Perl instance to another.

For instance:

perlbrew clone-modules 5.26.1 5.27.7

will clone all modules from instance 5.26.1 to instance 5.27.7.

For perlbrew version prior to 0.81 or in case the clone-modules does not what you need, the following one liner can pipe all modules from one instance of Perl to another one asking cpanm to install each one on the latter:

perlbrew list-modules | perlbrew exec --with perl-5.16.2@foo-project cpanm

The exec command is particularly helpful to run any program as if it is in the environment of the specified perl installations.

Get more details running the help command:

perlbrew help list-modules
perlbrew help exec
perlbrew help clone-modules
Clone this wiki locally