There are Debian packages, RPMs, FreeBSD ports, and packages for other operation systems available. If you want to use the package management system, search for cpanminus and use the appropriate command to install. This makes it easy to install cpanm to your system without thinking about where to install, and later upgrade.

If you have perl in your home directory, which is the case if you use tools like perlbrew, you don't need the --sudo option, since you're most likely to have a write permission to the perl's library path. You can just do:

OK, the first motivation was this: the CPAN shell runs out of memory (or swaps heavily and gets really slow) on Slicehost/linode's most affordable plan with only 256MB RAM. Should I pay more to install perl modules from CPAN? I don't think so.

First of all, let me be clear that CPAN and CPANPLUS are great tools I've used for literally years (you know how many modules I have on CPAN, right?). I really respect their efforts of maintaining the most important tools in the CPAN toolchain ecosystem.

However, for less experienced users (mostly from outside the Perl community), or even really experienced Perl developers who know how to shoot themselves in their feet, setting up the CPAN toolchain often feels like yak shaving, especially when all they want to do is just install some modules and start writing code.

It queries the CPAN Meta DB site at http://cpanmetadb.plackperl.org/. The site is updated at least every hour to reflect the latest changes from fast syncing mirrors. The script then also falls back to query the module at http://metacpan.org/ using its wonderful API.

Upon calling these API hosts, cpanm (1.6004 or later) will send the local perl versions to the server in User-Agent string by default. You can turn it off with --no-report-perl-version option. Read more about the option with cpanm, and read more about the privacy policy about this data collection at http://cpanmetadb.plackperl.org/#privacy

Fetched files are unpacked in ~/.cpanm and automatically cleaned up periodically. You can configure the location of this with the PERL_CPANM_HOME environment variable.

It installs to wherever ExtUtils::MakeMaker and Module::Build are configured to (via PERL_MM_OPT and PERL_MB_OPT). So if you're using local::lib, then it installs to your local perl5 directory. Otherwise it installs to the site_perl directory that belongs to your perl.

cpanminus at a boot time checks whether you have configured local::lib, or have the permission to install modules to the site_perl directory. If neither, it automatically sets up local::lib compatible installation path in a perl5 directory under your home directory. To avoid this, run the script as the root user, with --sudo option or with --local-lib option.