細かきこと

書いたり書かなかったり

perl環境の構築

perlbrewのインストール

perlのrbenvのようなもの。

複数のバージョンをインストールできて、使い分けできる。

\curl -L http://install.perlbrew.pl | bash

上記コマンド実行後、

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

とコンソールに表示されるので、指定されたようにシェルの環境設定ファイルでperlbrew用の設定を読み込むようにする。

で、再読み込み

source ~/.bash_profile

perlのインストール

perlbrew available

でバージョンを確認して、欲しいのを入れる

perl install perl-5.18.0

インストールが終わったら、入れたバージョンのperlにスイッチする

perlbrew switch 5.18.0

cpanmのインストール

CPAN::Shellを楽に使えるようにしたもの。

perlbrew install-cpanm

cartonのインストール

perlのBundlerみたいなもの。

cpanm Carton

とりあえず、Plackをいれてみる。

mkdir ~/hoge
cd hoge
echo 'requires "Plack";' > cpanfile
carton install

Plackの起動

下記のように、carton経由でplackupする

carton exec -- plackup -e "use Plack::App::Directory; Plack::App::Directory->new({root=>'./docs'})->to_app"

感想

perlの環境構築、特にcpanでモジュールをインストールしたり、アップデートしたりするところですごい苦労した記憶があるが、ずいぶんと楽になったものだ。

参考URL