Installing CPAN modules - a tutorial#
Sooner or later a pperl program needs something from CPAN. This tutorial covers how to get it, where it lands, how pperl finds it afterwards, and what to do when a distribution refuses to install.
You are assumed to have installed Perl modules before, with cpan, cpanm, or your distribution’s package manager. What follows is what changes when the interpreter is pperl rather than perl5.
The one idea#
pperl runs no XS. Not “XS is discouraged”, not “XS is slower” - a compiled extension cannot be loaded at all, because pperl is a Rust reimplementation of Perl 5 and does not have perl5’s C-level ABI to bind against.
Two consequences follow, and everything else in this tutorial is a detail of one of them.
Pure Perl installs; XS does not. A distribution written in Perl works exactly as it does anywhere else. A distribution that needs to compile C does not, and no amount of configuration will change that.
pperl has to introduce itself to the installer. Several hundred modules are built into the pperl binary and have no .pm file on disk. An installer decides “do I already have this?” by looking for that file, so without help it reads some other perl’s inventory and draws the wrong conclusion in both directions - rebuilding modules pperl already has, and believing it has ones it does not.
pperl --cpan exists to arrange both. It is not a new installer: it runs the CPAN client that ships with Perl, the one behind the cpan command, with the environment set up so the answers come out right.
pperl --cpan Text::CSV
What you will need#
Nothing besides pperl for the installer itself. The CPAN client is part of Perl’s core library, so it is built into the pperl binary and pperl runs it directly - inside that run, $^X is pperl and not a host perl. No perl5 has to be installed on the machine.
What a distribution’s own build needs is still needed: make for nearly all of them, and git if you install from a repository.
The client keeps its downloads, its build directories and its configuration under ~/.pperl/cpan. A ~/.cpan that belongs to a host perl is neither read nor changed.