CPAN(1perl)
π CPAN β the perl pragma page, but make it cute π
okay so bestie, welcome to CPAN(1perl), from the Perl Programmers Reference Guide. yes that CPAN. the big one. the one you type when you want perl modules to just exist on your machine. let's get into it π«Ά
β¨ NAME β¨
cpan β easily interact with CPAN from the command line. that's it, that's the vibe. π
πΈ SYNOPSIS πΈ
# with arguments and no switches, installs specified modules
cpan module_name [ module_name ... ]
# with switches, installs modules with extra behavior
cpan [-cfFimtTw] module_name [ module_name ... ]
# use local::lib
cpan -I module_name [ module_name ... ]
# one time mirror override for faster mirrors
cpan -p ...
# with just the dot, install from the distribution in the
# current directory
cpan .
# without arguments, starts CPAN.pm shell
cpan
# without arguments, but some switches
cpan [-ahpruvACDLOPX]
like, look at that. no arguments? shell mode. dot? installs whatever's in the current dir, iconic. π¦
π DESCRIPTION π
okay so here's the tea: this script gives you a command interface to CPAN β and like, not a shell, bestie, we're being precise here. as of rn it uses CPAN.pm to do all the actual work, but it is not a one-shot command runner for CPAN.pm. those are different things and the manpage wants you to know it. π
π Options π
-aβ creates aCPAN.pmautobundle withCPAN::Shell->autobundle. very "let me just snapshot everything" of it.-Amodule [ module ... ] β shows the primary maintainers for the modules you name. yes, you can find out who to @ about it. π-cmodule β runs amake cleaninside the specified module's directories. tidy girl summer. π§-Cmodule [ module ... ] β shows the Changes files for the specified modules. receipts!! π-Dmodule [ module ... ] β shows the module details. it prints one line for every out-of-date module, and "out-of-date" here means modules that are locally installed but have newer versions on CPAN. each line has three columns: module name, local version, and CPAN version. three lil columns of truth. β¨-fβ forces the specified action when it normally would have failed. use it to install a module even if its tests fail. and heads up: when you use this option,-iis not optional for installing a module when you need to force it:
% cpan -f -i Module::Foo
-Fβ turns offCPAN.pm's attempts to lock anything. β οΈ be careful with this one bestie, because you might end up with multiple scripts trying to muck around in the same directory. it's less of a concern if you're loading a special config with-jand that config sets up its own work directories.-gmodule [ module ... ] β downloads the latest distribution of the module to the current directory.-Gmodule [ module ... ] β UNIMPLEMENTED. π
for the record, what it would do: download the latest distribution of the modules to the current directory, unpack each distribution, and create a git repository for each distribution.
if you actually want this feature, go check out Yanick Champoux's Git::CPAN::Patch distribution.
-hβ prints a help message and exits. and when you specify-h, it ignores all the other options and arguments. main character behavior, honestly. it simply does not care.-imodule [ module ... ] β installs the specified modules. with no other switches, this switch is implied. so like, you were already doing it.-Iβ loadslocal::lib(think of it like-Ifor loading lib paths). too bad-lwas already taken. π-jConfig.pm β loads the file that has the CPAN configuration data. it should have the same format as the standardCPAN/Config.pmfile, which defines$CPAN::Configas an anonymous hash.-Jβ dumps the configuration in the same format thatCPAN.pmuses. super useful for checking your config, and also for using that dump as a starting point for a new custom configuration. π«Ά-lβ lists all installed modules with their versions.-Lauthor [ author ... ] β lists the modules by the specified authors.-mβ makes the specified modules.-Mmirror1,mirror2,... β a comma-separated list of mirrors to use for just this run. and the-Poption can find them for you automatically.-nβ does a dry run, but doesn't actually install anything. (unimplemented) π-Oβ shows the out-of-date modules.-pβ pings the configured mirrors and prints a report.-Pβ finds the best mirrors you could be using and uses them for the current session. glow-up for your download speeds. π₯-rβ recompiles dynamically loaded modules withCPAN::Shell->recompile.-sβ drops you into theCPAN.pmshell. this command does this automatically if you don't specify any arguments, so it's lowkey the default.-tmodule [ module ... ] β runs amake teston the specified modules.-Tβ do not test modules. simply install them. (chaotic, but go off.)-uβ upgrades all installed modules. β οΈ blindly doing this can really break things, so keep a backup. i'm not kidding, back it up.-vβ prints the script version and theCPAN.pmversion, then exits.-Vβ prints detailed information about thecpanclient.-wβ UNIMPLEMENTED.
what it would do: turn on cpan warnings. it checks various things, like directory permissions, and tells you about problems you might have.
-xmodule [ module ... ] β finds close matches to the named modules that you think you might have mistyped. this requires the optional installation ofText::LevenshteinorText::Levenshtein::Damerau. typos could never. β¨-Xβ dumps all the namespaces to standard output.
π Examples π
# print a help message
cpan -h
# print the version numbers
cpan -v
# create an autobundle
cpan -a
# recompile modules
cpan -r
# upgrade all installed modules
cpan -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 them
cpan -Ti CGI::Minimal URI
(yes, Netscape::Booksmarks is spelled like that in the example. i'm not touching it, that's the source, we respect the source π
)
πΈ Environment variables πΈ
so there are several components in CPAN.pm that use environment variables. the build tools β ExtUtils::MakeMaker and Module::Build β use some, while others matter to the levels above them. some of these are specified by the Perl Toolchain Gang:
Lancaster Consensus: <https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md>
Oslo Consensus: <https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/oslo-consensus.md>
NONINTERACTIVE_TESTINGβ assume no one is paying attention, and skip prompts for distributions that do that correctly.cpan(1)sets this to1unless it already has a value (even if that value is false).PERL_MM_USE_DEFAULTβ use the default answer for prompted questions.cpan(1)sets this to1unless it already has a value (even if that value is false).CPAN_OPTSβ same idea asPERL5OPT: a string of additionalcpan(1)options to add to the ones you specify on the command line.CPANSCRIPT_LOGLEVELβ the log level to use, whether with the embedded minimal logger or withLog::Log4perlif it's installed. possible values are the same as theLog::Log4perllevels:TRACE,DEBUG,INFO,WARN,ERROR, andFATAL. the default isINFO.GIT_COMMANDβ the path to thegitbinary to use for the Git features. the default is/usr/local/bin/git.
π EXIT VALUES π
the script exits with zero if it thinks everything worked, or a positive number if it thinks something failed. but β οΈ note that in some cases it has to divine a failure from the output of things it does not control. for now, the exit codes are vague:
1β an unknown error2β the was an external problem4β there was an internal problem with the script8β a module failed to install
(and yes, "The was an external problem" is exactly how it's written. we don't fix, we preserve. π)
π TO DO π
- one shot configuration values from the command line
π¦ BUGS π¦
- none noted β¨
π SEE ALSO π
most behaviour β including environment variables and configuration β comes directly from CPAN.pm.
β SOURCE AVAILABILITY β
this code lives on GitHub in the CPAN.pm repository:
https://github.com/andk/cpanpm
the source used to be tracked separately in another GitHub repo, but the canonical source is now in the above repo. periodt.
π CREDITS π
- Japheth Cleaver added the bits to allow a forced install (
-f). - Jim Brandt suggest and provided the initial implementation for the up-to-date and Changes features.
- Adam Kennedy pointed out that
exit()causes problems on Windows where this script ends up with a.batextension.
π AUTHOR π
brian d foy, "<bdfoy@cpan.org>"
πΈ COPYRIGHT πΈ
Copyright (c) 2001-2015, brian d foy, All Rights Reserved.
You may redistribute this under the same terms as Perl itself.
and that's the whole page bestie, we ate and left no crumbs π«Ά this was perl v5.44.0, dated 2026-10-17, filed under CPAN(1perl). go install something cute. π β¨
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms