====== Perlbrew ====== perlbrewは、ホームディレクトリに複数のperlをインストールして切り替えをしてくれるツールです ===== インストール ===== ==== FreeBSD ==== # pkg install p5-perlbrew ==== CentOS ==== perlやgccなどが必要です $ yum -y install perl gcc make $ curl -L http://install.perlbrew.pl | bash (略) ## 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. ===== 初期設定 ===== ==== FreeBSD ==== perlbrew init で初期化して、pathを設定する # perlbrew init perlbrew root (~/perl5/perlbrew) is initialized. Append the following piece of code to the end of your ~/.cshrc and start a new shell, perlbrew should be up and fully functional from there: source ~/perl5/perlbrew/etc/cshrc Simply run `perlbrew` for usage details. Happy brewing! # echo " source ~/perl5/perlbrew/etc/cshrc " >> .cshrc # source ~/.cshrc ==== CentOS ==== $ echo " source ~/perl5/perlbrew/etc/bashrc " >> .bashrc # zshの人は.zshrcを指定 $ source ~/.bashrc # 環境変数Reload ===== 利用できるPerlのバージョンを確認 ===== $ perlbrew available perl-5.19.11 perl-5.18.2 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 普通は最新版を入れれば良いでしょう((5.xxのxxの部分が奇数のバージョンは開発版なので注意)) ===== Perlインストール ===== $ perlbrew install 5.18.2 テストを省略しても良いなら、次のように「–notest」でインストールすると、少し早く終わります。 $ perlbrew install --notest 5.18.2 途中経過を見たい場合は別のSHellから $ tail -f ~/perl5/perlbrew/build.perl-5.18.2.log ===== Perlを切り替え ===== インストールリスト $ perlbrew list perl-5.18.2 Perlを切り替え $ perlbrew switch 5.18.2 もう一度perlbrew listで確認 $ perlbrew list * perl-5.18.2 頭に*印がついているのが、現在選択しているPerlです。 whichコマンドでperlコマンドのフルパスを確認してみましょう。 $ which perl /home/hogehoge/perl5/perlbrew/perls/perl-5.18.2/bin/perl ===== cpanmをインストール ===== $ perlbrew install-cpanm //cpanmのupdateもこのコマンド// cpanmについては以下を参照 [[development:language:perl:cpanm|]] ==== FreeBSD ==== cpanmのインストールにはcurlが必要ですので、先に pkg install curl をしてください。 でないと以下のようなエラーが出ます # perlbrew install-cpanm Certificate verification failed for /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 Extended Validation Server CA 34380826280:error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed:/usr/src/secure/lib/libssl/../../../crypto/openssl/ssl/s3_clnt.c:1168: fetch: https://github.com/miyagawa/cpanminus/raw/master/cpanm: Authentication error Page not retrieved: fetch failed. at /usr/local/lib/perl5/site_perl/5.16/App/perlbrew.pm line 87. ===== スクリプトのshebang (#!) ===== shebangを #!/usr/bin/env perl とする ===== cronで使う ===== perlbrewで入れたPerlをcronで使うには、いくつか設定が必要です。((普通に実行すると、システム標準のPerlが実行されてしまうので注意))\\ まず、次のようなシェルスクリプトを用意。 #!/bin/sh export HOME=/home/hogehoge source ~/perl5/perlbrew/etc/bashrc perlbrew use perl-5.18.2 exec "$@" crontabの設定はこんな感じ * * * * * /home/hogehoge/perlbrewenv.sh perl /home/hogehoge/hoge.pl > /tmp/hoge 2>&1 ===== Perlbrewを最新版に更新 ===== $ perlbrew self-upgrade ===== 参考 ===== [[http://d.hatena.ne.jp/hirose31/20121031/1351650951|perlbrewを使うにあたっていろいろな小細工をした件]]