Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CPAN Requirements File

With pip you are able to create a requirements file to specify which libraries to install. Is there an equivalent for perl modules using CPAN?

I came across ExtUtils::MakeMaker, but this seems like the make file is for each module specifically.

I guess to try and give a better idea of what I am asking is if there is a way to do something like

cpan install -r requirements.txt

and then specify which modules to install in that requirements file.

Thanks in advance!

like image 422
DoolAy Avatar asked Jul 09 '15 20:07

DoolAy


People also ask

What is a CPAN file?

The Comprehensive Perl Archive Network (CPAN) is a repository of over 250,000 software modules and accompanying documentation for 39,000 distributions, written in the Perl programming language by over 12,000 contributors.

How do I install CPAN modules?

To install Perl modules using CPAN, you need to use the cpan command-line utility. You can either run cpan with arguments from the command-line interface, for example, to install a module (e.g Geo::IP) use the -i flag as shown.

How do I know what CPAN modules are installed?

Available commands are: l - List all installed modules m - Select a module q - Quit the program cmd? Sample outputs: Installed modules are: JavaScript::SpiderMonkey Log::Log4perl Perl cmd?


1 Answers

When you install modules from CPAN, each module specifies its dependencies in the Makefile.PL (or Build.PL) and the CPAN shell will resolve those dependencies recursively when installing.

If you want to specify dependencies for an application (rather than a CPAN module), you can create a file called cpanfile in this format:

requires 'JSON';
requires 'Template';
requires 'DateTime';
requires 'DBIx::Class';

Then you can install those dependencies with one command:

cpanm --installdeps .

The cpanm command comes from the App::cpanminus distribution and is an alternative tool for installing modules from CPAN.

See the cpanfile docs for more information.

like image 110
Grant McLean Avatar answered Oct 04 '22 17:10

Grant McLean