Having a Brew
A new perl in five commands
First I need to setup perlbrew. This takes three commands (the latter two will be different on your system, but don't worry, in each case the previous command tells you what to do when you run it.)
curl -L http://xrl.us/perlbrewinstall | bash /Users/mark/perl5/perlbrew/bin/perlbrew init echo >>~/.bashrc "source /Users/mark/perl5/perlbrew/etc/bashrc"
Now to install and switch to the latest development version of perl I only need type:
perlbrew install perl-5.13.8 perlbrew switch perl-5.13.8
And to install and switch to the latest stable perl I only need to type:
perlbrew install perl-5.12.2 perlbrew switch perl-5.12.2
Again, in excruciating detail
If you're anything like me, you've seen this kind of quickfire instructions on the web before and it leaves you with questions. Wouldn't it be nice if someone posted a complete dump of exactly what was going on when these commands are run? Yes, it would be...
Let's start from the top again. First, download and install perlbrew with the one liner:
travis-4:~ mark$ curl -L http://xrl.us/perlbrewinstall | bash
Off it goes:
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 102 306 102 306 0 0 236 0 0:00:01 0:00:01 --:--:-- 2756 ## Download the latest perlbrew ## Installing The perlbrew is installed as: /Users/mark/perl5/perlbrew/bin/perlbrew You may trash the downloaded /private/tmp/perlbrew from now on. Next, if this is the first time you install perlbrew, run: /Users/mark/perl5/perlbrew/bin/perlbrew init And follow the instruction on screen. ## Done. (automatically removes downloaded /tmp/perlbrew)
We'd better follow its instructions, eh?
travis-4:~ mark$ /Users/mark/perl5/perlbrew/bin/perlbrew init
This prints out some more stuff, including an instruction to modify our path:
Perlbrew environment initiated, required directories are created under /Users/mark/perl5/perlbrew Well-done! Congratulations! Please add the following line to the end of your ~/.bashrc source /Users/mark/perl5/perlbrew/etc/bashrc After that, exit this shell, start a new one, and install some fresh perls: perlbrew install perl-5.12.1 perlbrew install perl-5.10.1 For further instructions, simply run: perlbrew The default help messages will popup and tell you what to do! Enjoy perlbrew at $HOME!!
Okay, let's modify our path to contain the instructions then:
travis-4:~ mark$ echo >>~/.bashrc "source /Users/mark/perl5/perlbrew/etc/bashrc"
Now we need to restart bash. The easiest way to do that is to close the current terminal and open a new one (and stops us getting confused.) After this, installing a new Perl is a doddle, with just a single command.
travis-4:~ mark$ perlbrew install perl-5.13.8
And it does all the hard work for us:
Attempting to load conf from /Users/mark/perl5/perlbrew/Conf.pm Fetching perl-5.13.8 as /Users/mark/perl5/perlbrew/dists/perl-5.13.8.tar.gz Installing perl-5.13.8 into /Users/mark/perl5/perlbrew/perls/perl-5.13.8 This could take a while. You can run the following command on another shell to track the status: tail -f /Users/mark/perl5/perlbrew/build.log (cd /Users/mark/perl5/perlbrew/build; tar xzf /Users/mark/perl5/perlbrew/dists/perl-5.13.8.tar.gz;cd /Users/mark/perl5/perlbrew/build/perl-5.13.8;rm -f config.sh Policy.sh;sh Configure -de '-Dprefix=/Users/mark/perl5/perlbrew/perls/perl-5.13.8' '-Dusedevel';make;make test && make install) >> '/Users/mark/perl5/perlbrew/build.log' 2>&1 Installed perl-5.13.8 as perl-5.13.8 successfully. Run the following command to switch to it. perlbrew switch perl-5.13.8
So, as it says, we can switch which perl we're using just by using the "perlbrew switch" command:
travis-4:~ mark$ perl -v This is perl, v5.10.0 built for darwin-thread-multi-2level (with 2 registered patches, see perl -V for more detail) Copyright 1987-2007, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. travis-4:~ mark$ perlbrew switch perl-5.13.8 travis-4:~ mark$ perl -v This is perl 5, version 13, subversion 8 (v5.13.8) built for darwin-2level Copyright 1987-2010, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
We can switch back to the system perl with the "perlbrew off" command:
travis-4:~ mark$ perlbrew off travis-4:~ mark$ perl -v This is perl, v5.10.0 built for darwin-thread-multi-2level (with 2 registered patches, see perl -V for more detail) Copyright 1987-2007, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
And that's about it. Very simple!