Linux command
cpan 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Install a Perl module
cpan [Module::Name]
Install multiple modules
cpan [Module::One] [Module::Two]
Start interactive CPAN shell
cpan
Force install a module
cpan -f [Module::Name]
Install from a specific mirror
cpan -M [http://cpan.org] [Module::Name]
Upgrade all installed modules
cpan -u
Get information about a module
cpan -D [Module::Name]
Install without testing
cpan -T [Module::Name]
说明
cpan is the standard command-line interface for installing Perl modules from the Comprehensive Perl Archive Network (CPAN). It handles dependency resolution, downloading, building, testing, and installation of Perl modules and their prerequisites. On first run, cpan enters a configuration mode to set up mirrors, build preferences, and other settings. This configuration is stored in ~/.cpan/CPAN/MyConfig.pm. Users can reconfigure later with o conf commands in the interactive shell. The interactive shell provides commands for searching (m /pattern/), installing (install Module), examining (look Module), and managing the local CPAN cache. Tab completion and command history are available in the shell. CPAN.pm downloads module distributions to ~/.cpan/sources/, extracts and builds them in ~/.cpan/build/, then installs to the Perl library path. On systems where users lack write access to system Perl directories, consider using local::lib or perlbrew for user-local installations.
参数
- -f
- Force installation, ignoring test failures.
- -F
- Turn off CPAN.pm's attempts to lock (use with caution).
- -i
- Install specified modules (default action).
- -T
- Do not test modules before installing.
- -t
- Run tests for the specified modules.
- -u
- Upgrade all installed modules.
- -D _module_
- Display module details and installation status.
- -M _mirror_
- Use the specified CPAN mirror.
- -O
- Show outdated modules.
- -a
- Create an autobundle of installed modules.
- -r
- Recompile dynamically loaded modules.
- -j _file_
- Use alternate configuration file.
- -g _module_
- Download to current directory without installing.
- -v
- Print CPAN.pm version.
FAQ
What is the cpan command used for?
cpan is the standard command-line interface for installing Perl modules from the Comprehensive Perl Archive Network (CPAN). It handles dependency resolution, downloading, building, testing, and installation of Perl modules and their prerequisites. On first run, cpan enters a configuration mode to set up mirrors, build preferences, and other settings. This configuration is stored in ~/.cpan/CPAN/MyConfig.pm. Users can reconfigure later with o conf commands in the interactive shell. The interactive shell provides commands for searching (m /pattern/), installing (install Module), examining (look Module), and managing the local CPAN cache. Tab completion and command history are available in the shell. CPAN.pm downloads module distributions to ~/.cpan/sources/, extracts and builds them in ~/.cpan/build/, then installs to the Perl library path. On systems where users lack write access to system Perl directories, consider using local::lib or perlbrew for user-local installations.
How do I run a basic cpan example?
Run `cpan [Module::Name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -f do in cpan?
Force installation, ignoring test failures.