Forgive a newbie question: what about virtualenv doesn't cut it?
On the other hand, perlbrew allows you to manage completely separate builds of perl, and the associated tools like cpan/cpanminus will install to whatever the currently selected Perl is.
For example, my perlbrew at work looks like this:
% tree -L 2 ~/perl5/perlbrew
~/perl5/perlbrew/
|-- Conf.pm
|-- bin
| |-- cpanm
| `-- perlbrew
|-- build
| |-- perl-5.12.3
| `-- perl-5.14.1
|-- build.log
|-- dists
| |-- perl-5.12.3.tar.gz
| `-- perl-5.14.1.tar.gz
|-- etc
| |-- bashrc
| `-- cshrc
`-- perls
|-- current -> perl-5.12.3
|-- perl-5.12.3
`-- perl-5.14.1
You source the appropriate ~/perl5/perlbrew/etc/{bash,csh}rc for your shell, which creates a shell function called perlbrew. % type perlbrew
perlbrew is a shell function
% perlbrew
Usage:
perlbrew <command> [options] [arguments]
Commonly used commands:
init Initialize perlbrew environment.
install Install perl
list List installed perls
use Use the specified perl in current shell
switch Permanently use the specified perl as default
mirror Pick a preferred mirror site
off Permanently turn off perlbrew
version Display version
help Read more detailed instructions
Examples:
perlbrew install perl-5.12.3
perlbrew install perl-5.13.6
perlbrew list
perlbrew use perl-5.13.6
perlbrew switch perl-5.12.3
perlbrew switch /path/to/special/perl
perlbrew switch /path/to/special/perl special-perl
# later
% perlbrew list
* perl-5.12.3
perl-5.14.1
/usr/local/bin/perl (5.8.8)
/usr/bin/perl (5.8.8)
% perlbrew version
~/perl5/perlbrew/bin/perlbrew - App::perlbrew/0.19
% perlbrew available
perl-5.15.1
i perl-5.14.1
perl-5.12.4
perl-5.10.1
perl-5.8.9
perl-5.6.2
perl5.005_04
perl5.004_05
perl5.003_07
% perlbrew install perl-5.10.1
Attempting to load conf from ~/perl5/perlbrew/Conf.pm
Fetching perl-5.10.1 as ~/perl5/perlbrew/dists/perl-5.10.1.tar.gz
Installing perl-5.10.1 into ~/perl5/perlbrew/perls/perl-5.10.1
This could take a while. You can run the following command on another shell
to track the status:
tail -f ~/perl5/perlbrew/build.log
(cd ~/perl5/perlbrew/build; tar xzf ~/perl5/perlbrew/dists/perl-5.10.1.tar.gz;
cd ~/perl5/perlbrew/build/perl-5.10.1;rm -f config.sh Policy.sh;patchperl;
sh Configure -de '-Dprefix=~/perl5/perlbrew/perls/perl-5.10.1';make ;make
test_harness && make install) >> '~/perl5/perlbrew/build.log' 2>&1
Installed perl-5.10.1 as perl-5.10.1 successfully. Run the following command
to switch to it.
perlbrew switch perl-5.10.1