ちょっと Perl 書いた。

最近、ネットがつながっていなくても、好きなタイミングでCPANモジュール入れてプログラミングしたいと思い、CPAN::Miniを入れてます。だけど、普段はネット繋がってるのでローカルのミラーが古くなるといやだなと思って、シェルを立ち上げたときに、minicpan を実行するか聞いてくれるようにしてみました。
あと、Amon2とかどんどん便利になってそうなので常に最新版を使えるように cpan-outdated | cpanm とかも実行するか聞かれるようにしてみました。適当ですが下記の感じ。

余談ですが、こういうツール類のインストールとかは @hidek さんのブログが網羅的な感じでいいかんじだと思いました。
http://blog.hide-k.net/archives/2010/11/perl_3.php

#!/usr/bin/env perl
use 5.14.0;
use warnings;

my @cmds = (
    'minicpan',
    'cpan-outdated | cpanm'
);

ask_and_go($_) for @cmds;

sub ask_and_go {
    my $cmd = shift;
    print "Do you want to run `$cmd` ? [no]: ";
    chomp(my $input = <>);
    return unless $input ~~ /^y/i;
    say `$cmd`;
}


以下、実行結果。

Last login: Thu Nov 10 16:41:56 on ttys000
Do you want to run `minicpan` ? [no]: y
Updating /Users/hirofumi/mirrors/cpan/
Mirroring from http://ftp.riken.jp/lang/CPAN/
===============================================================
authors/01mailrc.txt.gz ... resulted in an HTTP error with status 500
http://ftp.riken.jp/lang/CPAN/authors/01mailrc.txt.gz: 500 Server closed connection without sending any data back
modules/02packages.details.txt.gz ... updated
modules/03modlist.data.gz ... up to date
authors/id/B/BI/BINGOS/POE-Component-SmokeBox-Recent-1.34.tar.gz ... updated
authors/id/B/BI/BINGOS/CHECKSUMS ... updated
authors/id/B/BR/BRADH/Sub-Mage-0.004.tar.gz ... resulted in an HTTP error with status 500
http://ftp.riken.jp/lang/CPAN/authors/id/B/BR/BRADH/Sub-Mage-0.004.tar.gz: 500 Server closed connection without sending any data back
authors/id/D/DA/DANAJ/Data-BitStream-0.04.tar.gz ... updated
authors/id/D/DA/DANAJ/CHECKSUMS ... updated
authors/id/D/DA/DANAJ/Data-BitStream-XS-0.02.tar.gz ... updated
authors/id/D/DR/DRSTEVE/Net-LastFMAPI-0.2.tar.gz ... updated
authors/id/D/DR/DRSTEVE/CHECKSUMS ... updated
authors/id/G/GN/GNUSTAVO/modules/SVN-Hooks-1.10.tar.gz ... updated
authors/id/G/GN/GNUSTAVO/modules/CHECKSUMS ... updated
authors/id/J/JA/JAK/File-Value-1.02.tar.gz ... updated
authors/id/J/JA/JAK/CHECKSUMS ... updated
authors/id/J/JJ/JJNAPIORK/MooseX-Role-BuildInstanceOf-0.07.tar.gz ... updated
authors/id/J/JJ/JJNAPIORK/CHECKSUMS ... updated
authors/id/K/KE/KENTARO/Module-Install-PrePAN-0.01.tar.gz ... updated
authors/id/K/KE/KENTARO/CHECKSUMS ... updated
authors/id/L/LE/LECSTOR/PDF-Boxer-0.002.tar.gz ... updated
authors/id/L/LE/LECSTOR/CHECKSUMS ... updated
authors/id/L/LL/LLAP/Plack-Middleware-TemplateToolkit-0.25.tar.gz ... updated
authors/id/L/LL/LLAP/CHECKSUMS ... updated
authors/id/M/MA/MARKSTOS/CGI.pm-3.57.tar.gz ... updated
authors/id/M/MA/MARKSTOS/CHECKSUMS ... updated
authors/id/M/MD/MDOOTSON/Alien-wxWidgets-0.54.tar.gz ... updated
authors/id/M/MD/MDOOTSON/CHECKSUMS ... updated
authors/id/M/MD/MDOOTSON/Wx-0.9903.tar.gz ... updated
authors/id/M/MI/MIRK/Net-Z3950-SimpleServer-1.15.tar.gz ... updated
authors/id/M/MI/MIRK/CHECKSUMS ... updated
authors/id/N/NE/NEIKON/Algorithm-KNN-XS-0.01001.tar.gz ... updated
authors/id/N/NE/NEIKON/CHECKSUMS ... updated
authors/id/P/PJ/PJB/MIDI-ALSA-1.13.tar.gz ... updated
authors/id/P/PJ/PJB/CHECKSUMS ... updated
authors/id/R/RE/REEDFISH/Net-FullAuto-0.9981.tar.gz ... updated
authors/id/R/RE/REEDFISH/CHECKSUMS ... updated
authors/id/R/RE/REID/Algorithm-Pair-Best-1.036.tar.gz ... updated
authors/id/R/RE/REID/CHECKSUMS ... updated
authors/id/R/RK/RKITOVER/DBIx-Class-Schema-Loader-0.07012.tar.gz ... updated
authors/id/R/RK/RKITOVER/CHECKSUMS ... updated
authors/id/R/RW/RWSTAUNER/Dist-Zilla-Plugin-Run-0.013.tar.gz ... updated
authors/id/R/RW/RWSTAUNER/CHECKSUMS ... updated
authors/id/S/SM/SMUELLER/Math-ConvexHull-MonotoneChain-0.01.tar.gz ... updated
authors/id/S/SM/SMUELLER/CHECKSUMS ... updated
authors/id/S/SQ/SQUEEK/App-CPAN-MetaDB-0.01.tar.gz ... updated
authors/id/S/SQ/SQUEEK/CHECKSUMS ... updated
authors/id/T/TO/TOBYINK/HTML-HTML5-Microdata-ToRDFa-0.100.tar.gz ... updated
authors/id/T/TO/TOBYINK/CHECKSUMS ... updated
authors/id/T/TO/TOBYINK/RDF-Prefixes-0.002.tar.gz ... updated
authors/id/T/TO/TOKUHIROM/Amon2-3.22.tar.gz ... updated
authors/id/T/TO/TOKUHIROM/CHECKSUMS ... updated
authors/id/W/WR/WROG/Net-OpenID-Common-1.14.tar.gz ... updated
authors/id/W/WR/WROG/CHECKSUMS ... updated
authors/id/Z/ZI/ZIGOROU/Test-Mock-Guard-0.07.tar.gz ... updated
authors/id/Z/ZI/ZIGOROU/CHECKSUMS ... updated

Do you want to run `cpan-outdated | cpanm` ? [no]: y
--> Working on T/TO/TOKUHIROM/Amon2-3.22.tar.gz
Fetching http://search.cpan.org/CPAN/authors/id/T/TO/TOKUHIROM/Amon2-3.22.tar.gz ... OK
Configuring Amon2-3.22 ... OK
Building and testing Amon2-3.22 ... OK
Successfully installed Amon2-3.22
1 distribution installed