[ Perl tips index ]
[ Subscribe to Perl tips ]
Many developers have a chicken-and-egg problem when it comes to upgrading their version of Perl. On one hand, the system version of Perl cannot be upgraded because it might break existing scripts, on the the other hand it has been difficult to install your own version of Perl to see whether an upgrade is safe. The same happens with modules.
Use App::perlbrew to install and switch between multiple versions of
Perl. perlbrew is easy to install, even if you don't have system
administration privileges, and very easy to use. Once you've installed and
initialised it, you can install whichever version of Perl you wish to use.
perlbrew install perl-5.12.2
perlbrew install perl-5.10.1
perlbrew will then fetch, compile and install that version of Perl in
your home directory (or other nominated location) and you then you can just
start using that version (perlbrew will do all the path magic required
to make this your default version of Perl).
If you have more than one version of Perl installed by perlbrew you can
list the verions out:
perlbrew list
and switch between them:
perlbrew switch perl-5.12.2
You can also ask perlbrew to switch itself off so that you can go back
to using the system Perl.
perlbrew off
local::lib helps solve the problem when a Perl package on your machine
isn't the version you need it to be. It allows you to create your own
directory of Perl packages into your own, or your team's directory.
use local::lib;
# or
use local::lib '/path/to/team/directory';
local::lib also sets up some useful shell commands which add our
preferred include directories to PERL5LIB in our environment. If our
code is not running under taint, we don't even need to add the use line
to our code to use these newly installed modules.
App::cpanminus makes installing modules a breeze. In combination with
local::lib it makes installing modules locally simple and easy.
cpanm --local-lib Test::Most
or, if you're using local::lib's environment variables:
cpanm Test::Most
Note that each cpanm install is specific to the version of Perl you were
using when you installed it. While this is generally not a problem, if you
locally installed cpanm while using Perl 5.8.8 then attempting to install a
module that requires a minimum of Perl 5.10.1, then cpanm will object
even if you are now using Perl 5.12.1.
If you wish to have a portable, off-line CPAN mirror, or wish to maintain
the state of CPAN exactly as it was at a particular date, then
CPAN::Mini is the way to go:
cpanmini -l ~/local-cpan -r http://search.cpan.org/CPAN
We can even use this with cpanm:
cpanm --mirror ~/local-cpan --mirror-only Test::Most
cpanmini only includes the most recent versions of the CPAN modules
(rather than their whole history) and as a consequence is only a few
Gigabytes.
[ Perl tips index ]
[ Subscribe to Perl tips ]
This Perl tip and associated text is copyright Perl Training Australia. You may freely distribute this text so long as it is distributed in full with this Copyright noticed attached.
If you have any questions please don't hesitate to contact us:
| Email: | contact@perltraining.com.au |
| Phone: | 03 9354 6001 (Australia) |
| International: | +61 3 9354 6001 |
Copyright 2001-2012 Perl Training Australia. Contact us at contact@perltraining.com.au