perl dependency management extUtils::Installed list into a container

Viewed 68

In python we have pip install -r requirements.txt. Is there something similar in perl?

How can I go from this ExtUtils::Installed list and first install the given perl, and then the correct versioned modules?

./installed.pl 
DBD::SQLite - 1.66
DBI - 1.643
Perl - 5.26.1

Extutils works on directory paths and .packlists

1 Answers

Sounds like cpanfile with cpanm is a good fit here.

Your container should first install the correct perl (say with perlbrew) and then App::cpanminus. After that, a file called cpanfile corresponds to the requirements.txt or .packlist above and would look like

requires 'DBI' => '1.643';
requires 'DBD::SQLite' => '1.66';

which you install with cpanm --installdeps . will install the rest.

That file formats specifies the minimum versions of those modules, an implicit >=. If you need to pin a specific version, use == or avoid a version with !=.

The cpanfile format is flexible, allowing you to conditionally install modules using --with-develop flags, etc.

Edit: there are those who prefer the speed of cpm over cpanm for installing lots of modules. It takes some shortcuts (skips tests by default) that shouldn't make a difference in a stable environment.

Related