Perlbrew&Perlのインストール

今日は、PerlbrewとPerlのインストールを行います。環境はMacbook Air/OSX 10.8.4 MountainLionです。

1.Perlbrewのインストール

Perlbrewをインストールします。

$ curl -kL http://install.perlbrew.pl | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   315    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  1022  100  1022    0     0    269      0  0:00:03  0:00:03 --:--:--  2682

## Download the latest perlbrew

## Installing perlbrew
perlbrew is installed: ~/perl5/perlbrew/bin/perlbrew

perlbrew root (~/perl5/perlbrew) is initialized.

Append the following piece of code to the end of your ~/.bash_profile and start a
new shell, perlbrew should be up and fully functional from there:

    source ~/perl5/perlbrew/etc/bashrc

Simply run `perlbrew` for usage details.

Happy brewing!

## Installing patchperl

## Done.

Perlbrewのインストール時に表示された~/perl5/perlbrew/etc/bashrcをbashで読み込むように設定します。
~/.bash_profile

# perlbrew
if ! which perlbrew > /dev/null; then
    source "$HOME/perl5/perlbrew/etc/bashrc"
fi

設定を読み込んで、Perlbrewを初期化します。

$ . ~/.bash_profile
$ perlbrew init

perlbrew root (~/perl5/perlbrew) is initialized.

Append the following piece of code to the end of your ~/.bash_profile and start a
new shell, perlbrew should be up and fully functional from there:

    source ~/perl5/perlbrew/etc/bashrc

Simply run `perlbrew` for usage details.

Happy brewing!

2.Perlのインストール

インストール可能なPerlのバージョンをリストします。

$ perlbrew available
  perl-5.19.2
  perl-5.18.0
  perl-5.16.3
  perl-5.14.4
  perl-5.12.5
  perl-5.10.1
  perl-5.8.9
  perl-5.6.2
  perl5.005_04
  perl5.004_05
  perl5.003_07

現在の最新版であるperl-5.19.2をインストールします(ただし、安定版はマイナーバージョンが偶数のものだそうです)。

$ perlbrew install 5.19.2
Fetching perl 5.19.2 as /Users/irie/perl5/perlbrew/dists/perl-5.19.2.tar.bz2
Installing /Users/irie/perl5/perlbrew/build/perl-5.19.2 into ~/perl5/perlbrew/perls/perl-5.19.2

This could take a while. You can run the following command on another shell to track the status:

  tail -f ~/perl5/perlbrew/build.perl-5.19.2.log

perl-5.19.2 is successfully installed.

確認してみます。

$ perlbrew list
  perl-5.19.2

標準で使用するバージョンを指定します。

$ perlbrew switch 5.19.2
$ perlbrew list
* perl-5.19.2

参考

下記サイトを参考にさせて頂きました。