As a system administrator, I like keeping the Perl installation from a vendor pristine, whether it is from Sun or a Linux distribution, because they typically package tools that depend on the packaged Perl and Perl modules. They try to keep that Perl, and the modules they choose to package with it, stable and secure for everyone who uses their OS. For most folks, the packaged Perl is enough, but some people need newer (or older) versions of packaged modules, or they need to install modules that are not packaged. Upgrading packaged modules outside of the packaging scheme, or installing new and/or non-packaged modules, could have a destabilizing effect on your packaged Perl installation.

Also, I like to change default Perl installs quickly and easily. I have had to upgrade Perl for a bunch of scripts that used the #!/usr/local/bin/perl she-bang line. Modifying each script to test with the new Perl version, then replacing the "Old Perl" with the "Test Perl" and modifying the scripts again was "too much fooling around".

It turns out that having your own custom Perl, or even a few of them, isn't very costly. I'll use an example with four different Perl versions.

If it turns out that you are not a system administrator, but you want to excersize the same amount of control over your Perl installations, then give
Perlbrew a try!

Now I could answer all the "file path" related questions with /usr/local/perl588/cpan/ instead of /home/$USER/.cpan/, but I will edit the file later, so I let it "autoconfigure" as much as it can, including finding the closest mirrors. At the end of the configuration process I type exit at the prompt.

I edit it the file name the configuration process said it wrote at the end:

vi /usr/local/perl5101/lib/5.8.8/CPAN/Config.pm

and I change the paths:

'build_dir' => q[/usr/local/perl588/cpan/build],

'histfile' => q[/usr/local/perl588/cpan/histfile],

'keep_source_where' => q[/usr/local/perl588/cpan/sources],

'prefs_dir' => q[/usr/local/perl588/cpan/prefs],

to the /usr/local/perl588/cpan/ prefix if I "autoconfigured" everything, and I will put my mirror (leave it alone if you don't have one) at the front of the "urllist" variable:

Now I could answer all the "file path" related questions with /usr/local/perl5101/cpan/ instead of /home/$USER/.cpan/, but I will edit the file later, so I let it "autoconfigure" as much as it can, including finding the closest mirrors. At the end of the configuration process I type exit at the prompt.

I edit it the file name the configuration process said it wrote at the end:

vi /usr/local/perl5101/lib/5.10.1/CPAN/Config.pm

and I change the paths:

'build_dir' => q[/usr/local/perl5101/cpan/build],

'histfile' => q[/usr/local/perl5101/cpan/histfile],

'keep_source_where' => q[/usr/local/perl5101/cpan/sources],

'prefs_dir' => q[/usr/local/perl5101/cpan/prefs],

to the /usr/local/perl5101/cpan/ prefix if I "autoconfigured" everything, and I will put my mirror (leave it alone if you don't have one) at the front of the "urllist" variable:

Now I could answer all the "file path" related questions with /usr/local/perl5122/cpan/ instead of /home/$USER/.cpan/, but I will edit the file later, so I let it "autoconfigure" as much as it can, including finding the closest mirrors. At the end of the configuration process I type exit at the prompt.

I edit it the file name the configuration process said it wrote at the end:

vi /usr/local/perl5122/lib/5.12.2/CPAN/Config.pm

and I change the paths:

'build_dir' => q[/usr/local/perl5122/cpan/build],

'histfile' => q[/usr/local/perl5122/cpan/histfile],

'keep_source_where' => q[/usr/local/perl5122/cpan/sources],

'prefs_dir' => q[/usr/local/perl5122/cpan/prefs],

to the /usr/local/perl5122/cpan/ prefix if I "autoconfigured" everything, and I will put my mirror (leave it alone if you don't have one) at the front of the "urllist" variable:

Now I could answer all the "file path" related questions with /usr/local/perl5142/cpan/ instead of /home/$USER/.cpan/, but I will edit the file later, so I let it "autoconfigure" as much as it can, including finding the closest mirrors. At the end of the configuration process I type exit at the prompt.

I move the file name the configuration process said it wrote at the end
to a common location and then edit it:

At the prompt I ask CPAN to install the CPAN and LWP "bundles" (and required supporting modules):

install Bundle::CPAN Bundle::LWP Task::Plack

I will observe whether the file fetching parts used my mirror or not. If not, my mirror may be down, or more likely I mis-keyed the configuration file.

Common Flexible Binary

To make the different versions of Perl easy to use and change, the Perl binaries have to be in the PATH. Typically /usr/local/bin/ is in the path, so that is where I want to put my Perl binaries. Because I want to use my custom Perl binaries by default, I will check my path and make sure /usr/local/bin/ comes before /usr/bin/ (or wherever the packaged Perl binaries are located)
[1].

I will then create a default Perl symbolic link at /usr/local/perl and point it at the Perl version I want to use by default.

su -
cd /usr/local/
ln -s perl5122 perl

I also want the other versions to be available without typing the full path, so I will do this:

Install A Snapshot

I usually want the same modules installed in all versions of Perl I have installed. If you already have the modules installed in one installation of Perl (and the modules are in CPAN), you can make a snapshot of your installation and easily install it in another. Lets say that I have all the modules I want installed in my 5.10.1 installation of Perl. If so, I can:

/usr/local/perl5101/bin/perl -MCPAN -e autobundle

A whole lot of output will be produced and at the end it will print Wrote bundle file and a file path (in this instance /usr/local/perl5101/cpan/Bundle/Snapshot_2010_09_16_00.pm). I will take this file and use it to install the listed modules in my new 5.12.2 installation of Perl:

If there are a lot of modules to install it could take a considerable amount time. I often use screen to make it easier on me.

Keeping Perl Up To Date

This process I layout is "uncareful" with regard to Perl installation stability. Somethings may break when you install all the newest versions of every module installed. If this prospect bothers you, you may want to install a "Test Perl" (the same version as the one you want to keep stable, maybe at /usr/local/perl5122test/) and try out the upgrade there first.

If you don't care, and just want the latest of everything, just do this:

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license should be available
here
and
here.
The current copy of this document should be available
here.