HTTP::Async

非同期のHTTPリクエストを生成する っぽい

#!/usr/bin/perl
#Time-stamp: <07/03/03 14:10:43 hiroya>

use strict;
use warnings;
use HTTP::Async;
use HTTP::Request;

use HTTP::Async;
my $async = HTTP::Async->new;

my @urls  = qw{
  http://f.hatena.ne.jp/images/fotolife/h/hiboma/20070125/20070125184632.jpg
  http://f.hatena.ne.jp/images/fotolife/h/hiboma/20070206/20070206003742.jpg
  http://d.hatena.ne.jp/images/diary/h/hiboma/hiboma_p.gif
  http://f.hatena.ne.jp/images/fotolife/h/hiboma/20070205/20070205164213.jpg
  http://f.hatena.ne.jp/images/fotolife/h/hiboma/20070205/20070205164013.jpg
};

map { $async->add( HTTP::Request->new( GET => $_ ) ) } @urls;

# $async->add( HTTP::Request->new( GET => 'http://hiroya.dyndns.org' ) );
# $async->add( HTTP::Request->new( GET => 'http://b.hatena.ne.jp/' ) );


while ( my $r = $async->wait_for_next_response ) {
    printf( "%s %s\n", $r->base, $r->header('Content-Length') );
}