pperlbrew - When shall we three meet again?
Childhood's End
promised a perlbrew for three perls. Here it is. pperlbrew is
perlbrew - Kang-min Liu's App-perlbrew 1.03, commands, build options
and layout included - plus two things. It keeps three implementations
side by side and switches between them: perl, PetaPerl and
PerlOnJava. And it installs on a Linux machine that has no perl,
because it brings one along: a pperl of 8.4 MB, which is that
machine's first perl from then on. One line of shell does it. Where a
perl exists, so does cpanm App::pperlbrew.
A perl to get a perl
For a decade and a half perlbrew has been the answer to "I need a
different perl than the one on this machine". It builds any perl from
source into your home directory, as many as you like, and one command
decides which of them perl means. It is written in Perl, so its
installer looks for a perl first, and without one it stops: "Need
/usr/bin/perl or /usr/local/bin/perl".
On a workstation that costs nothing. In a small container image, on
an embedded board, or wherever somebody removed /usr/bin/perl on
purpose, it is the end of the road: to get the perl you want, you
need a perl you did not choose.
No perl required
curl -fsSL https://perl.petamem.com/downloads/pperlbrew/install.sh | sh
That is the installation, run as a normal user. Here it is in a sandbox that holds BusyBox, curl with its libraries and certificates, and nothing else:
$ command -v perl
$ curl -fsSL https://perl.petamem.com/downloads/pperlbrew/install.sh | sh
package.tar.gz: OK
pperl: OK
Installed /home/test/perl5/pperlbrew/bin/pperlbrew
To activate in this shell, run
. '/home/test/perl5/pperlbrew/etc/bashrc'
$ . '/home/test/perl5/pperlbrew/etc/bashrc'
$ pperlbrew version
pperlbrew - App::pperlbrew/0.2612040
The installer is a single shell script of 115 kB with the manager inside. It downloads one more file: the newest minimal pperl for the machine's architecture, currently 0.6.27 at 8.4 MB for x86-64 and 8.1 MB for ARM64. It needs a shell, curl, base64, tar and sha256sum; BusyBox has them all.
That one binary does two jobs. It runs the manager, 3,400 lines of
Perl, nearly nine in ten of them perlbrew's. And it is the first perl
in pperlbrew list: a machine that had no perl has one now, and a
machine that had one keeps it until you switch.
It is a small perl. A minimal pperl is what miniperl is to perl: the
language and a basic set of modules, statically linked, no JIT. The
manager gets by on that; it leaves checksums to sha256sum and
copying to cp. For everything else there is the full pperl, one
command away, in the next section.
A binary that starts is not a binary that works
A checksum proves that the file is the one we published. It cannot
prove that we published the right one, and we have not always: the
minimal 0.6.25 builds for ARM64 and RISC-V start, then misread what
the file system says about a file. The installer refuses those two by
checksum and takes no other build at its word. Before anything is
activated, the downloaded pperl has to prove itself on this machine:
its Config describes this architecture, a file test and a directory
test give the right answer, an exception is caught, and the manager
runs. One failure, and nothing is installed.
If you would rather not pipe the internet into a shell, you have a
point, and two reassurances. The script is function definitions down
to its last line, which is the call, so a download that breaks off
defines some functions and runs none. And it writes only under
~/perl5/pperlbrew and ~/.pperlbrew, plus one activation line in
your shell's startup file, which PPERLBREW_NO_PROFILE=1 leaves to
you. Or download it and read it first: about 250 lines of shell and a
block of base64.
Three perls
$ pperlbrew available pperl
# pperl
pperl-0.6.25
pperl-0.6.25-dynamic-max-jitp-dbi-pdl-shell-webgpu
pperl-0.6.25-dynamic-max-jitp-shell
$ pperlbrew install pperl-0.6.25
Fetching https://perl.petamem.com/downloads/pperl-0.6.25-x86_64-static-max-jitp-shell
pperl-0.6.25 is successfully installed.
$ pperlbrew install 5.42.0
$ pperlbrew install -n jperl-5.44.1
Each family is installed the way it comes:
- perl is built from source by perlbrew's own code, unchanged,
with every option perlbrew has:
--thread,--64int,--as,-D,-j. It needs a C compiler, as always. - pperl is a binary, downloaded and checked against the SHA-256
the manager carries for it.
--frominstalls any pperl executable you have, your own build included. - jperl is PerlOnJava,
Flavio Glock's Perl for the Java virtual machine. It is built from
the tagged source with Gradle and needs JDK 24 or later.
-nskips its test suite, as it does perl's.
A pperl or jperl is installed only once it has run a line of Perl. After that the three are equals:
$ pperlbrew use pperl-0.6.25
$ command -v perl
/home/test/perl5/pperlbrew/perls/pperl-0.6.25/bin/perl
The selected one answers to perl as well as to its own name, so
#!/usr/bin/env perl and perl Makefile.PL reach it. use selects
for this shell, switch for every later one, off and switch-off
undo them. lib, alias, clone-modules and the rest work as they
do in perlbrew.
In the play, the answer to the title is "when the hurlyburly's done". Here it is one command:
pperlbrew exec --with perl-5.42.0,jperl-5.44.1,pperl-0.6.25 perl script.pl
One script, three implementations, each output under its name. When we announced pperl we wrote that two implementations checking each other are the strongest correctness argument there is. Three are stronger, and the one that disagrees with the other two has a bug report coming. Often enough it will be ours.
Beside perlbrew
pperlbrew leaves a perlbrew installation alone. It has its own root,
~/perl5/pperlbrew, its own settings in ~/.pperlbrew and its own
PPERLBREW_* variables.
Sharing a shell is another matter. Both managers rewrite PATH and
both restore a saved selection in every new terminal, so with both
active, the order of two lines in a startup file decides which perl
you get. The installer therefore stops when it finds perlbrew, before
it downloads or writes anything, and names the two ways on: remove
perlbrew, or pass --force and keep both in separate directories.
The CPAN distribution declares the same conflict with App::perlbrew.
While a perlbrew is still around, every pperlbrew command says so on
standard error, then runs.
We advise one manager, and pperlbrew can be it, since it builds perl
with perlbrew's code. It does not adopt the perls perlbrew already
built: list them with perlbrew list and install them again.
This is no verdict on perlbrew. pperlbrew exists because perlbrew does, most of its lines are Kang-min Liu's, and both are under the MIT licence.
With a perl
Where a perl is installed, CPAN is the way:
cpanm App::pperlbrew
pperlbrew init
. "$HOME/perl5/pperlbrew/etc/bashrc"
The manager then runs on the perl that installed it, 5.10.1 or later, whatever you select afterwards, and downloads a pperl only when you ask for one. The version, 0.2612040, is a date: 2026-12-04, first of the day.
The fine print
- Linux only, like pperl.
- No bootstrap on RISC-V. There is no sound minimal pperl for it yet.
- No full pperl for ARM64 in the catalog.
available pperllists x86-64 builds. On ARM64 the minimal pperl of the bootstrap is what you start with; a full one goes in with--from, without the JIT for now. - The catalog ships with the manager: pperl 0.6.25 in three
builds, jperl 5.44.0 and 5.44.1. A newer release arrives with
pperlbrew self-upgrade, or sooner with--from. - A perl, not a toolchain. Building perl takes a C compiler,
building jperl a JDK and Gradle, and pperlbrew brings neither. The
Gradle wrapper of jperl 5.44.1 also refuses Java 27; point
JAVA_HOMEat a JDK 25. - One day old. Its tests are perlbrew's, adapted, plus the sandbox installation above. Other people's machines are the test it has yet to pass.
Getting pperl
"A binary to download is what pperl has been so far", the last post said, and named a perlbrew as the first step beyond that. Done. Next on that list: containers, distribution packages or AppImages, whichever turn out to serve. No dates.
curl -fsSL https://perl.petamem.com/downloads/pperlbrew/install.sh | sh
- Richard C. Jelinek, PetaMem s.r.o.
Leave a comment