Linux "cpan" Command Line Options and Examples
easily interact with CPAN from the command line

This script provides a command interface (not a shell) to CPAN. At the moment it uses CPAN.pm to do the work, but it is not a one- shot command runner for CPAN.


Usage:

# with arguments and no switches, installs specified modules
cpan module_name [ module_name ... ]




Command Line Options:

-a
Creates a CPAN.pm autobundle with CPAN::Shell->autobundle.
cpan -a ...
-A
Shows the primary maintainers for the specified modules.
cpan -A ...
-c
Runs a `make clean` in the specified module's directories.
cpan -c ...
-C
Show the Changes files for the specified modules
cpan -C ...
-D
Show the module details. This prints one line for each out-of-date module (meaning, modules locally installed but have newerversions on CPAN). Each line has three columns: module name, local version, and CPAN version.
cpan -D ...
-g
Downloads to the current directory the latest distribution of the module.
cpan -g ...
-G
UNIMPLEMENTEDDownload to the current directory the latest distribution of the modules, unpack each distribution, and create a git repositoryfor each distribution.If you want this feature, check out Yanick Champoux's "Git::CPAN::Patch" distribution.
cpan -G ...
-h
Print a help message and exit. When you specify "-h", it ignores all of the other options and arguments.
cpan -h ...
-i
Install the specified modules. With no other switches, this switch is implied.
cpan -i ...
-I
Load "local::lib" (think like "-I" for loading lib paths). Too bad "-l" was already taken.
cpan -I ...
-j
Load the file that has the CPAN configuration data. This should have the same format as the standard CPAN/Config.pm file, whichdefines $CPAN::Config as an anonymous hash.
cpan -j ...
-l
List all installed modules with their versions
cpan -l ...
-L
List the modules by the specified authors.
cpan -L ...
-m
Make the specified modules.
cpan -m ...
-M
A comma-separated list of mirrors to use for just this run. The "-P" option can find them for you automatically.
cpan -M ...
-n
but don't actually install anything. (unimplemented)
cpan -n ...
-O
Show the out-of-date modules.
cpan -O ...
-p
Ping the configured mirrors and print a report
cpan -p ...
-P
Find the best mirrors you could be using and use them for the current session.
cpan -P ...
-r
Recompiles dynamically loaded modules with CPAN::Shell->recompile.
cpan -r ...
-s
Drop in the CPAN.pm shell. This command does this automatically if you don't specify any arguments.
cpan -s ...
-t
Run a `make test` on the specified modules.
cpan -t ...
-T
Do not test modules. Simply install them.
cpan -T ...
-u
Upgrade all installed modules. Blindly doing this can really break things, so keep a backup.
cpan -u ...
-v
Print the script version and CPAN.pm version then exit.
cpan -v ...
-V
Print detailed information about the cpan client.
cpan -V ...
-w
Turn on cpan warnings. This checks various things, like directory permissions, and tells you about problems you might have.
cpan -w ...
-x
Find close matches to the named modules that you think you might have mistyped. This requires the optional installation ofText::Levenshtein or Text::Levenshtein::Damerau.
cpan -x ...
-X
Examples# print a help messagecpan -h# print the version numberscpan -v# create an autobundlecpan -a# recompile modulescpan -r# upgrade all installed modulescpan -u# install modules ( sole -i is optional )cpan -i Netscape::Booksmarks Business::ISBN# force install modules ( must use -i )cpan -fi CGI::Minimal URI# install modules but without testing themcpan -Ti CGI::Minimal URIEnvironment variablesThere are several components in CPAN.pm that use environment variables. The build tools, ExtUtils::MakeMaker and Module::Build usesome, while others matter to the levels above them. Some of these are specified by the Perl Toolchain Gang:Lancaster Concensus: <https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md>Oslo Concensus: <https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/oslo-consensus.md>NONINTERACTIVE_TESTINGAssume no one is paying attention and skips prompts for distributions that do that correctly. cpan(1) sets this to 1 unless italready has a value (even if that value is false).PERL_MM_USE_DEFAULTUse the default answer for a prompted questions. cpan(1) sets this to 1 unless it already has a value (even if that value isfalse).CPAN_OPTSAs with "PERL5OPTS", a string of additional cpan(1) options to add to those you specify on the command line.CPANSCRIPT_LOGLEVELThe log level to use, with either the embedded, minimal logger or Log::Log4perl if it is installed. Possible values are the sameas the "Log::Log4perl" levels: "TRACE", "DEBUG", "INFO", "WARN", "ERROR", and "FATAL". The default is "INFO".GIT_COMMANDThe path to the "git" binary to use for the Git features. The default is "/usr/local/bin/git".EXIT VALUESThe script exits with zero if it thinks that everything worked, or a positive number if it thinks that something failed. Note,however, that in some cases it has to divine a failure by the output of things it does not control. For now, the exit codes arevague:1 An unknown error2 The was an external problem4 There was an internal problem with the script8 A module failed to installTO DO* one shot configuration values from the command lineBUGS* none noted
cpan -X ...