App::cpm::Tutorial - How to use cpm
$ cpm install Module
cpm is yet another CPAN client (like cpan, cpanp, and cpanm), which is fast!
From CPAN:
$ cpanm -nq App::cpm
Or, download a self-contained cpm:
$ curl -sL --compressed https://git.io/cpm > cpm $ chmod +x cpm $ ./cpm --version # you can even install modules without installing cpm $ curl -sL --compressed https://git.io/cpm | perl - install Plack
$ cpm install Plack
This command installs Plack into ./local, and you can use it by
./local
$ perl -I$PWD/local/lib/perl5 -MPlack -E 'say Plack->VERSION'
If you want to install modules into current INC instead of ./local, then use --global/-g option.
--global/-g
$ cpm install --global Plack
By default, cpm outputs only DONE install Module things. If you want more verbose messages, use --verbose/-v option.
DONE install Module
--verbose/-v
$ cpm install --verbose Plack
cpm can handle version range notation like cpanm. Let's see some examples.
$ cpm install Plack~'> 1.000, <= 2.000' $ cpm install Plack~'== 1.0030' $ cpm install Plack@1.0030 # this is an alias of ~'== 1.0030'
cpm can install dev releases (TRIAL releases).
$ cpm install Moose@dev # if you prefer dev releases for not only Moose, # but also its dependencies, then use global --dev option $ cpm install --dev Moose
And cpm can install modules from git repositories directly.
$ cpm install git://github.com/skaji/Carl.git
If you omit arguments, and there exists cpanfile in the current directory, then cpm loads modules from cpanfile, and install them
cpanfile
$ cat cpanfile requires 'Moose', '2.000'; requires 'Plack', '> 1.000, <= 2.000'; $ cpm install
Moreover if you have cpanfile.snapshot, then cpm tries to resolve distribution names from it
cpanfile.snapshot
$ cpm install -v 30186 DONE resolve (0.001sec) Plack -> Plack-1.0030 (from Snapshot) ...
This is an experimental and fun part! cpm supports git/dist syntax in cpanfile.
$ cat cpanfile requires 'Carl', git => 'git://github.com/skaji/Carl.git'; requires 'Perl::PrereqDistributionGatherer', git => 'https://github.com/skaji/Perl-PrereqDistributionGatherer', ref => '3850305'; # ref can be revision/branch/tag
Please note that to support git/dist syntax in cpanfile wholly, there are several TODOs.
There are CPAN modules that create darkpans (minicpan, CPAN mirror) such as CPAN::Mini, OrePAN2, Pinto.
Such darkpans store distribution tarballs in
DARKPAN/authors/id/A/AU/AUTHOR/Module-0.01.tar.gz
and create the de facto standard index file 02packages.details.txt.gz in
02packages.details.txt.gz
DARKPAN/modules/02packages.details.txt.gz
If you want to use cpm against such darkpans, change the cpm resolver by --resolver/-r option:
--resolver/-r
$ cpm install --resolver 02packages,http://example.com/darkpan Module $ cpm install --resolver 02packages,file::///path/to/darkpan Module
Sometimes, your darkpan is not whole CPAN mirror, but partial, so some modules are missing in it. Then append --resolver metadb option to fall back to normal MetaDB resolver:
--resolver metadb
$ cpm install \ --resolver 02packages,http://example.com/darkpan \ --resolver metadb \ Module
To install App::cpm, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::cpm
CPAN shell
perl -MCPAN -e shell install App::cpm
For more information on module installation, please visit the detailed CPAN module installation guide.