homebrewでperl 5.16を入れる(→perlbrewでやりなおそうかなぁ)

なんでもかんでもhomebrewで入れたがる[twitter:@riocampos]です。

プレインストールされているPerlのバージョンなどを確認。

admin$ which perl 
/usr/bin/perl
admin$ perl -v

This is perl 5, version 12, subversion 3 (v5.12.3) built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)

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.

まずhomebrew/versionsをtapする

admin$ brew search perl
perl-build
homebrew/versions/perl514		homebrew/versions/perl518
homebrew/versions/perl516

ではtap。

admin$ brew tap homebrew/versions
Cloning into '/usr/local/Library/Taps/homebrew-versions'...
remote: Counting objects: 1082, done.
remote: Compressing objects: 100% (643/643), done.
remote: Total 1082 (delta 586), reused 902 (delta 439)
Receiving objects: 100% (1082/1082), 284.50 KiB | 180.00 KiB/s, done.
Resolving deltas: 100% (586/586), done.
Checking connectivity... done
Tapped 103 formula

perl 5.16のinfoを確認

admin$ brew info perl516
perl516: stable 5.16.3
http://www.perl.org/

This formula is keg-only.
System provides Perl. Also conflicts with other Perl versions.

/usr/local/Cellar/perl516/5.16.3 (0B)
  Built from source
From: https://github.com/homebrew/homebrew-versions/commits/master/perl516.rb
==> Options
--use-dtrace
	Build with DTrace probes

brew install

admin$ brew install perl516
==> Downloading http://www.cpan.org/src/5.0/perl-5.16.3.tar.gz
######################################################################## 100.0%
==> ./Configure -des -Dprefix=/usr/local/Cellar/perl516/5.16.3 -Dman1dir=/usr/lo
==> make
==> make test
==> make install
==> Caveats
This formula is keg-only: so it was not symlinked into /usr/local.

System provides Perl. Also conflicts with other Perl versions.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/perl516/lib

==> Summary
🍺  /usr/local/Cellar/perl516/5.16.3: 2907 files, 60M, built in 16.9 minutes

17分もかかるとは…。
しかもいま入れたperlへのリンクは張られていない。
いま入れたファイルはどうなってるか。

admin$ brew list perl516
/usr/local/Cellar/perl516/5.16.3/bin/zipdetails
/usr/local/Cellar/perl516/5.16.3/bin/xsubpp
/usr/local/Cellar/perl516/5.16.3/bin/splain
/usr/local/Cellar/perl516/5.16.3/bin/shasum
/usr/local/Cellar/perl516/5.16.3/bin/s2p
/usr/local/Cellar/perl516/5.16.3/bin/ptargrep
/usr/local/Cellar/perl516/5.16.3/bin/ptardiff
/usr/local/Cellar/perl516/5.16.3/bin/ptar
/usr/local/Cellar/perl516/5.16.3/bin/pstruct
/usr/local/Cellar/perl516/5.16.3/bin/psed
/usr/local/Cellar/perl516/5.16.3/bin/prove
/usr/local/Cellar/perl516/5.16.3/bin/podselect
/usr/local/Cellar/perl516/5.16.3/bin/podchecker
/usr/local/Cellar/perl516/5.16.3/bin/pod2usage
/usr/local/Cellar/perl516/5.16.3/bin/pod2text
/usr/local/Cellar/perl516/5.16.3/bin/pod2man
/usr/local/Cellar/perl516/5.16.3/bin/pod2latex
/usr/local/Cellar/perl516/5.16.3/bin/pod2html
/usr/local/Cellar/perl516/5.16.3/bin/pl2pm
/usr/local/Cellar/perl516/5.16.3/bin/piconv
/usr/local/Cellar/perl516/5.16.3/bin/perlthanks
/usr/local/Cellar/perl516/5.16.3/bin/perlivp
/usr/local/Cellar/perl516/5.16.3/bin/perldoc
/usr/local/Cellar/perl516/5.16.3/bin/perlbug
/usr/local/Cellar/perl516/5.16.3/bin/perl5.16.3
/usr/local/Cellar/perl516/5.16.3/bin/perl
/usr/local/Cellar/perl516/5.16.3/bin/libnetcfg
/usr/local/Cellar/perl516/5.16.3/bin/json_pp
/usr/local/Cellar/perl516/5.16.3/bin/instmodsh
/usr/local/Cellar/perl516/5.16.3/bin/h2xs
/usr/local/Cellar/perl516/5.16.3/bin/h2ph
/usr/local/Cellar/perl516/5.16.3/bin/find2perl
/usr/local/Cellar/perl516/5.16.3/bin/enc2xs
/usr/local/Cellar/perl516/5.16.3/bin/cpanp-run-perl
/usr/local/Cellar/perl516/5.16.3/bin/cpanp
/usr/local/Cellar/perl516/5.16.3/bin/cpan2dist
/usr/local/Cellar/perl516/5.16.3/bin/cpan
/usr/local/Cellar/perl516/5.16.3/bin/corelist
/usr/local/Cellar/perl516/5.16.3/bin/config_data
/usr/local/Cellar/perl516/5.16.3/bin/c2ph
/usr/local/Cellar/perl516/5.16.3/bin/a2p
/usr/local/Cellar/perl516/5.16.3/lib/5.16.3/ (2042 files)
/usr/local/Cellar/perl516/5.16.3/share/man/ (819 files)

ってことは、/usr/local/Cellar/perl516/5.16.3/bin/perlにリンクを張ればいいのかしら。
…どこから?
/usr/binでlsしてみると

admin$ ls -l | grep perl
-rwxr-xr-x   1 root   wheel       807 May 17  2012 cpanp-run-perl
-rwxr-xr-x   1 root   wheel       565 May 17  2012 cpanp-run-perl5.10
-rwxr-xr-x   1 root   wheel       574 May 17  2012 cpanp-run-perl5.12
-rwxr-xr-x   1 root   wheel       807 May 17  2012 find2perl
-rwxr-xr-x   1 root   wheel     23628 May 17  2012 find2perl5.10
-rwxr-xr-x   1 root   wheel     23628 May 17  2012 find2perl5.12
-rwxr-xr-x   1 root   wheel     62784 May 17  2012 perl
-rwxr-xr-x   1 root   wheel     35328 May 17  2012 perl5.10
-rwxr-xr-x   1 root   wheel     35584 May 17  2012 perl5.12
-rwxr-xr-x   1 root   wheel       807 May 17  2012 perlbug
-rwxr-xr-x   1 root   wheel     45379 May 17  2012 perlbug5.10
-rwxr-xr-x   1 root   wheel     46014 May 17  2012 perlbug5.12
-rwxr-xr-x   1 root   wheel       807 May 17  2012 perldoc
-rwxr-xr-x   1 root   wheel       253 May 17  2012 perldoc5.10
-rwxr-xr-x   1 root   wheel       253 May 17  2012 perldoc5.12
-rwxr-xr-x   1 root   wheel       807 May 17  2012 perlivp
-rwxr-xr-x   1 root   wheel     12332 May 17  2012 perlivp5.10
-rwxr-xr-x   1 root   wheel     12483 May 17  2012 perlivp5.12
-rwxr-xr-x   1 root   wheel       807 May 17  2012 perlthanks
-rwxr-xr-x   1 root   wheel     45379 May 17  2012 perlthanks5.10
-rwxr-xr-x   1 root   wheel     46014 May 17  2012 perlthanks5.12

となる。
…なんか面倒そうだな。(中断)

perlbrewでやりなおそうかな

perlbrewは、ホームディレクトリに複数のperlをインストールして切り替えをしてくれるツールです。
http://www.seeds-std.co.jp/seedsblog/611.html

Rubyのrbenvみたいなものかしら。管理者でなくてもいけるのなら、perlbrewのほうがよさそうだな。