Read this article to know how to configure and use a CPAN client.
cpanPerl comes with a builtin CPAN client, named ehm cpan.
Be aware that your configuration is stored in the ~/.cpan/CPAN/MyConfig.pm file.
Do not edit that file, use
o confinstead from the cpan interactive shell, see below.
First runIt is really easy to start, just launch
and hit enter (two times) to accept defaults. It will be enough to let you prompt into an interactive shell so you can start install modules.
$ cpan CPAN.pm requires configuration, but most of it can be done automatically. If you answer 'no' below, you will enter an interactive dialog for each configuration option instead. Would you like to configure as much as possible automatically? [yes]
Give it a try installing Perl::Tidy
If it ends with an OK you are done, just type q to exit interactive shell.
cpan install Perl::Tidy
Continue with Configuration if cpan is working and you want to configure it to achieve greater user experience
... SHANCOCK/Perl-Tidy-20130922.tar.gz /home/bi/software/make/current/bin/make install OK cpan q Terminal does not support GetHistory. Lockfile removed.
or go to cpanminus if you want a zero config, minimal and efficient CPAN client
otherwise read Troubleshooting if you had problems during installation.
Two things could not work: network or permissions.
The quickest workaround is to check your network configuration and launch commands using sudo.
I really recommend to avoid using cpan and perl provided by your system. See Install your own Perl with your own CPAN or .software to know how to install Perl in some location your user owns.
local::lib approachBy the way, cpan will realize if you have not write permission and will ask what approach do you want: default is local::lib that is a good idea if you don’t want to build your own Perl.
For example, I use it on Codio and works great: just keep hitting enter and cpan will install local::lib for you.
After installation, you need to modify your environment manually. Just launch
$ cd ~/perl5/lib/perl5 $ perl -Mlocal::lib >> ~/.bash_profile $ source ~/.bash_profile # or reconnect
HelpJust type h in a cpan shell
ConfigurationYou can reconfigure all cpan client options by launching
type no and follow instructions.
o conf init CPAN.pm requires configuration, but most of it can be done automatically. If you answer 'no' below, you will enter an interactive dialog for each configuration option instead. Would you like to configure as much as possible automatically? [yes] no
In particular, if you need cpan pick mirrors for you, launch
and hit enter.
o conf init urllist
Get CPAN latest versionSTRONGLY RECOMMENDED
First of all, make sure you have CPAN.pm module updated to latest version
install CPAN ... reload CPAN
Always commit changes to config variables to disk.
o conf auto_commit 1
For the rest of this article I assume auto_commit is on.
Note that auto_commit is disabled by default, so you should launch o conf commit to confirm configuration changes.
Command number in promptPERSONAL
Disable the command number in the prompt.
o conf commandnumber_in_prompt 0
You need to install the following modules
install Term::ReadLine::Perl Term::ReadKey
Install YAML Perl module
and try to install a faster YAML implementation
It will need a C compiler installed on your system. If installation is successful, tell cpan which YAML implementation you prefer.
o conf yaml_module YAML::XS
Make sure LWP is installed and up to date
so cpan will use it to fetch files from Internet.
CPAN::SQLite is a layer between the index files that are downloaded
from the CPAN and CPAN.pm that speeds up metadata queries and reduces memory consumption of CPAN.pm considerably.
To use CPAN::SQLite launch
o conf use_sqlite yes
Build prerequisites automaticallyRECOMMENDED
The CPAN.pm module can detect when a module which you are trying to build depends on prerequisites. If this happens, I prefer it builds the prerequisites automatically instead of asking for confirmation.
I prefer to install prerequisites also when it is only needed for building or testing in order to save time on future installations.
o conf prerequisites_policy follow o conf build_requires_install_policy yes
or choose your favourite colors
o conf colorize_output yes o conf colorize_print bold white on_black o conf colorize_warn bold red on_black o conf colorize_debug green on_black
o conf init /colorize/
In general, CPAN is English speaking territory, so the character set does not matter much but some modules have names that are outside the ASCII range. Since my terminal supports UTF-8, I set
o conf term_is_latin no
Upgrade modulesPrint modules that can be upgraded.
Both commands accept a
/regexp/as argument. See Help.
cpanminusApp::cpanminus is a gift from Perl community angel Tatsuhiko Miyagawa.
It’s dependency free (can bootstrap itself), requires zero configuration, and stands alone. When running, it requires only 10MB of RAM.I assuming you already have a working cpan client, so to install cpanminus just launch
$ cpan App::cpanminus
cpanfrom now on. It is light, fast and minimal CPAN client, but, it has many features too: see cpanm or
cpanm -hto see what cpanminus can do.
You can use App::cpanoutdated to detect outdated CPAN modules in your environment.
then update all modules with
$ cpanm App::cpanoutdated
Note that also cpan has the upgrade modules feature but cpan-outdated is faster, uses less memory and is integrated with cpanm.
$ cpan-outdated | cpanm