在Mac OS X裡用CPAN

有個perl的腳本有用到YAML,但是Mac OS X的perl並沒有內建此模組,自己動手CPAN來裝又不想寫花/Library。就用local-lib來做好了。先載一個local-lib回來。

cd local-lib-1.008004
perl Makefile.PL --bootstrap
make
make test
make install

這會在家目錄下建一個perl5的目錄來放lib。接下來要設置一些環境變量就好了。

perl -I$HOME/perl5/lib/perl5 -Mlocal::lib

要是bash可以直接把上面的輸出貼到bashrc既可,csh要轉成setenv。

setenv PERL_LOCAL_LIB_ROOT "~/perl5";
setenv PERL_MB_OPT "--install_base ~/perl5";
setenv PERL_MM_OPT "INSTALL_BASE=~/perl5";
setenv PERL5LIB "~/perl5/lib/perl5/darwin-thread-multi-2level:~/perl5/lib/perl5";
set path = ( ~/perl5/bin \ #後面省略

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.