CPAN Commands
The Comprehensive Perl Archive Network (CPAN) is a vast repository of Perl modules. The cpan
command-line utility is your primary tool for interacting with CPAN to install, manage, and query modules. Mastering these commands is crucial for any Perl developer.
Install and Manage Perl Modules with CPAN
Below are essential cpan
commands to streamline your Perl development workflow. These commands cover common tasks such as installing modules, handling dependencies, and inspecting module information without installation.
Basic Module Installation
Install one or more modules by simply listing their names. CPAN will resolve dependencies and install them automatically.
# Install one or more modules
cpan <Some::Module> [Another::Module]
Advanced Installation Options
Explore options for more control over the installation process, including forcing installations, using local libraries, and skipping tests.
# Force install a module (useful for reinstalling or overwriting)
cpan -fi <Some::Module>
# Install a module in a local::lib directory for isolated environments
cpan -I <Some::Module>
# Install a module while skipping all tests to speed up the process
cpan -T <Some::Module>
# Download a distribution archive without installing it
cpan -g <Some::Module>
# Install the module in the current distro directory (e.g., after downloading)
cpan .
Module Information and Inspection
Query CPAN for module details, changes, or installed versions without performing an installation.
# See a module's changes, without installing it
cpan -C <Some::Module>
# See a module's details, without installing it
cpan -D <Some::Module>
# List close matches to a module's name
cpan -x <Some::Mdule>
# List all installed modules with their versions
cpan -l
CPAN Shell and Documentation
Access the interactive CPAN shell for a more dynamic experience or refer to the comprehensive documentation.
# Start the CPAN shell for interactive use
cpan
cpan -s
# Read the complete cpan documentation
perldoc cpan
Further Resources
For more in-depth information on Perl and module management, consult the official CPAN documentation and related resources:
- MetaCPAN: The official web interface for CPAN.
- Perl Documentation: Official Perl documentation.
- Perl.org: The official Perl programming language website.