« 2009年07月16日 | メイン | 2009年07月23日 »

2009年07月21日

CPANモジュール一括アップデート

Web::Scraperを使って欲しいデータだけ拾おうとしているんですが、
Webサイトによって上手くいったり上手く行かなかったり。
今ターゲットにしているサイトは上手く行かないタイプで、XPATHを書いて取得しようとしても
最初の1件しかデータを取って来れない。
(何か書き方に問題があるのかな?原因不明。。。orz)

藁をもすがる思いでWeb::Scraperをアップデートしようと思ったんですが…
TerminalでCPANに入ったとたん何か言ってきた。
CPAN is the world-wide archive of perl resources. It consists of about
300 sites that all replicate the same contents around the globe. Many
countries have at least one CPAN site already. The resources found on
CPAN are easily accessible with the CPAN.pm module. If you want to use
CPAN.pm, lots of things have to be configured. Fortunately, most of
them can be determined automatically. If you prefer the automatic
configuration, answer 'yes' below.

If you prefer to enter a dialog instead, you can answer 'no' to this
question and I'll let you configure in small steps one thing after the
other. (Note: you can revisit this dialog anytime later by typing 'o
conf init' at the cpan prompt.)
Would you like me to configure as much as possible automatically? [yes] 

え?初期設定?前にやったはずだけど…と思いながらそのままEnter。
自動的にだーっとやってくれるんだけど、最後に以下の文章が。
 
If no urllist has been chosen yet, would you prefer CPAN.pm to connect
to the built-in default sites without asking? (yes/no)? [no]

Autoconfigured everything but 'urllist'.
Please call 'o conf init urllist' to configure your CPAN server(s) now!

これは参照URLを設定しろってことなのね、ということで。
CPAN> o conf init urllist
すると「URL入力して」って言われるので、ここら辺りから適当に近いとこをコピペ。

で、最後にそれを反映させる。
CPAN> o conf commit

多分これで設定はOK。
しっかし何も触ってないはずなんだけど、なんで再設定になったんだろう?

あとは本題のCPANモジュール一括アップデート。
su して root になってから行う。
# 古いモジュールを一覧表示
$ perl -MCPAN -e 'CPAN::Shell->r'
# 一括アップデート
$ perl -MCPAN -e 'CPAN::Shell->install(CPAN::Shell->r)'