2015. 3. 6.

perl HTTP:Async call sample

use HTTP::Async;
use LWP::UserAgent;

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

for($idx=0; $idx<10; $idx++){
 
 $async->add( HTTP::Request->new( GET => 'http://www.daum.com/'         ) );
    $async->add( HTTP::Request->new( GET => 'http://www.google.com/' ) );
}



while ( my $response = $async->wait_for_next_response ) {
        # Do some processing with $response
        my $comple = $async->to_return_count;
        my $total = $async->total_count;
        my $progress = $async->in_progress_count;
       print "complete:  $comple, total:$total, progress:$progress \n";
    }

댓글 없음:

댓글 쓰기