I recently needed to run 32-bit Perl 5.8 on a 64-bit Centos 6 system. Initial research suggested that perlbrew would be the easiest way of achieving this, but I wasn’t able to find a walkthrough.
Here’s what worked for me…
1. Install perlbrew
You’ll need to install perlbrew from the CPAN, and it has a load of dependencies. The wonderful App::cpanminus makes this experience as painless as possible, so I installed it before moving onto perlbrew itself.
1 2 3
1. Initialise perlbrew
Next, get perlbrew ready for use. Pay attention to the output of the
init step – it will direct you to make a change to your shell configuration.
2. Install 32-bit Libraries
Installing these two packages was enough to build a 32-bit perl core. If you’re building additional XS modules against the 32-bit perl, they may require other 32-bit libraries to be installed.
3. Build A Perl
1 2 3 4 5 6 7 8 9
That’s all there is to it, though the result isn’t quite perfect. While the above invocation builds a 32-bit perl, it doesn’t override the system’s archname – so the resulting @INC looks like this:
1 2 3 4 5 6
For my purposes, this is simply an aesthetic issue – the x86_64-linux directories contain 32-bit shared objects – and I chose not to spend any more time perfecting it. If you happen to know which option(s) I’m missing, please leave a comment below.