Cpanm - Perl Module Installer

Install Perl modules easily with cpanm, a fast and simple CPAN client. Learn how to install modules from CPAN, URLs, local files, and configure dependencies.

Cpanm

cpanm is a lightweight and fast CPAN client for Perl. It simplifies the process of installing Perl modules from CPAN, local files, or URLs. This tool is essential for any Perl developer looking to manage their project dependencies efficiently.

Install Perl Modules with Cpanm

The primary function of cpanm is to install Perl modules. Below are common usage patterns:

---
tags: [ perl ]
---
see https://github.com/miyagawa/cpanminus

# install Some::Module
cpanm <Some::Module>

# install from CPAN distribution path, like AUTHOR/Some-Module-1.00.tar.gz
cpanm <cpan-repo-path>

# install from URL
cpanm <URL-to-distro-file>

# install from a local file
cpanm <path-to-distro-file>

# Configure interactively
cpanm --interactive <Some::Module>

# install from local directory
cpanm .

# install all the deps for the current directory
cpanm --installdeps .

# install Some::Module and all non-core deps into extlib
cpanm -L extlib <Some::Module>

# use the fast-syncing mirror
cpanm --mirror <mirror-url> <Some::Module>

# use only the HTTPS mirror
cpanm --from https://some.mirror.host/ <Some::Module>

Managing Perl Dependencies

cpanm is particularly useful for managing project dependencies. The --installdeps . command allows you to install all required modules for your current project directory, ensuring a smooth development environment setup.

Advanced Cpanm Configurations

For more specific installation needs, cpanm offers options like installing modules into a custom library directory (-L extlib) or specifying a particular CPAN mirror to use for faster downloads.

External Resources for Perl Development