我需要在Perl中创建一些并发的XML feed请求.什么是最快的做到这一点呢?
我可能会使用AnyEvent,也许是这样的:
use AnyEvent; use AnyEvent::HTTP; sub get_feeds { my @feeds = @_; my $done = AnyEvent->condvar; my %results; $done->begin( sub { $done->send(\%results) } ); for my $feed (@feeds){ $done->begin; http_get $feed, sub { $results{$feed} = \@_; $done->end }; } $done->end; return $done; } my $done = get_feeds(...); my $result = $done->recv; # block until all feeds are fetched