perlbrewで5.12.0の環境構築

カジュアルPerl #2で話題になったperlbrewを使って、Perl 5.12.0環境を構築してみました。

perlbrewは、perlCPANモジュールもホームディレクトリ以下に全部インストールして、OSアップデート時の影響を受けないようにします。
perlbrewを使えば、local::libはいらないらしいです。


まずは、perlbrewをインストールします。

$ wget http://xrl.us/perlbrew
$ chmod +x perlbrew
$ ./perlbrew install

初期化。

$ $HOME/perl5/perlbrew/bin/perlbrew init

設定ファイルを.bashrcに読み込ませます。

$ echo "source $HOME/perl5/perlbrew/etc/bashrc" >> ~/.bashrc
$ . .bashrc

パスの確認。

$ which perlbrew
$HOME/perl5/perlbrew/bin/perlbrew


次に、perlbrewを使ってPerlをインストールします。

$ perlbrew install perl-5.12.0

インストールした5.12.0に切り替えます。

$ perlbrew switch perl-5.12.0
$ perl -v

This is perl 5, version 12, subversion 0 (v5.12.0) built for x86_64-linux

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.

インストール済みのPerlは、"perlbrew installed"で確認できます。
アクティブになっているものに、"*"が付いています。

$ perlbrew installed
perl-5.12.0(*)
/usr/bin/perl

perlbrewを使えば、様々なバージョンのPerlをインストールし、簡単に切り替えができます。*1
コードを書く時は、シェバング行を"#!/usr/bin/env perl"にします。

*1:切り替え時は、$HOME/perl5/perlbrew/bin/perlへのシンボリックリンクが変更されます