Install perl to $HOME

作者:   發佈於:  

Since Perl 5.10.1 RC1 is out, it's time to build my new shiny Perl!

I installed perl inside my $HOME directory ( /Users/gugod ), and here's the way to do it:

cd ~/src; tar xzf perl-5.10.1-RC1.tar.gz
cd perl-5.10.1-RC1 
perl Configure -de -Dprefix=${HOME}/local
make
make test
make install

The -Dprefix=${HOME}/local makes it install to ~/local. Then you'll find the perl executable at ~/local/bin/perl. Therefore I also add ~/local/bin to my PATH:

export PATH=${HOME}/local/bin:${PATH}

Why am I doing that ? Mostly because that it doesn't require "sudo" when installing cpan modules with cpan or cpanp command. Therefore, if I need to move my $HOME to another machine (eg, when I buy a new Mac), it's much more easier - I'll just have to rsync my ~/local.

It's also useful when it's too much trouble upgrading system perl, or when you don't really want to upgrade system perl, but want to play with those shiny Perl 5.10 features.

Update: chas.owens pointed out that one of the Cwd test will fail if the perl is building in /tmp, because /tmp is really /private/tmp on OSX. I modified this post to use ~/src as my building path.