Having learnt from my previous mistakes, this is a simplistic way to set up multiple somewhat isolated installs of Perl in a user profile
App::perlbrew is a very handy tool for managing several user-installs of Perl, and facilitates the easy switching between Perl versions.
App::cpanminus is the most straight-forward and lightweight cpan client I've ever seen, and it just works, and works well, and leads to relatively pain-free installation 80% of the time.
1. Install A Bare copy of Perlbrew
Getting a copy of Perlbrew should be the very first thing you do. No cpanm, no local::lib, just straight perlbrew.$ cd ~ $ curl -LO http://xrl.us/perlbrew
2. Setup Perlbrew
Once we have a copy of perlbrew, we run the install command of it, which completes the bootstrapping of perlbrew. Then all thats needed is to update your profile with the right magic line so that new shells will have the right environment set up.$ perl ~/perlbrew install $ rm ~/perlbrew $ ~/perl5/perlbrew/bin/perlbrew init # use the line perlbrew spits out. $ echo "source /home/test_1/perl5/perlbrew/etc/bashrc" | tee -a ~/.bashrc
3. Enter your new perlbrew ENV
Now we enter our new shell so that we can test the change to our configuration. We run env and grep the PATH value just to double check perlbrew has worked properly.$ bash $ env | grep PATH PATH=/home/test_1/perl5/perlbrew/bin:/home/test_1/perl5/perlbrew/perls/current/bin:/home/test_1/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games:.
4. Choose a mirror
This step is mostly optional, but it lets you choose which mirror perlbrew will download Perl sources from, so a local one is best for speed sakes.$ perlbrew mirror
5. Install your wanted perl versions
Now we perform the slow installation of our Perls. In my case, I'm installing a copy of the current stable ( 5.12.2 ) and the current development release ( 5.13.2 ). The -v is optional, but you'll want it if you do not wish to die of boredom because it generally just sits there doing nothing for 10+ minutes without it.$ perlbrew -v install perl-5.12.2 $ perlbrew -v install perl-5.13.4
6. Setup 'cpanm' for each perl
This step appears to be the most important step. If you previously had cpanm installed with system perl you do NOT want to be using that at all. When cpanm is installed, the bin/ script hard-codes a path to the perl it was installed with, so using cpanm built with system perl will build installed modules using that system perl instead, and using its install paths and soforth, and you do not want this. So, you must install a cpanm for each perl using this bootstrap technique.$ perlbrew switch perl-5.12.2 $ curl -L http://cpanmin.us | perl - App::cpanminus $ perlbrew switch perl-5.13.4 $ curl -L http://cpanmin.us | perl - App::cpanminus
7. Configure local cpans
Strangely, I've found a few modules I try install tend to expect a working CPAN install, regardless of what tool I'm actually using. This should be fixed, but there is a practical work-around until then. Simply configure cpan!$ perlbrew switch perl-5.12.2 $ cpan # Answer all setup instructions » o conf commit » q $ perlbrew switch perl-5.13.4 $ cpan # Answer all setup instructions » o conf commit » q
8. Test your installs
This is a list of things I've found to trip up various corner cases and indicate you've built it wrong.$ perlbrew switch perl-5.12.2 $ cpanm --interactive -v App::cpanoutdated $ cpan-outdated $ cpanm --interactive -v App::CPAN::Fresh $ perlbrew switch perl-5.13.4 $ cpanm --interactive -v App::cpanoutdated $ cpan-outdated $ cpanm --interactive -v App::CPAN::FreshWith all things going to plan, those 2 things at least should build and be runnable. cpan-outdated and cpanf should both be runnable in both perls without complaining it cant find their modules, and CPAN::Inject and Compress::BZip2 should install without strange failures. ( those 2 modules lead me in prior cases to discover broken setups that needed fixing to work, so hopefully, going to plan, following the instructions above will avoid this havoc. )
9. Profit!
Thats all there is to it. Note we do NOT use local::lib for this setup. Using each Perls default local module installation directory should be perfectly satisfactory, and as long as you're in a properly configured ENV and you're using 'perlbrew' to select perl's that are not system perl, everything should be sweet =).Ok, lots of things on my machine fail to build still, but those peskynesses I'm convinced are unrelated to the Perl setup.