Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > multi-threading

Reply
Thread Tools

multi-threading

 
 
Jason Quek
Guest
Posts: n/a
 
      12-03-2003
Hi

I have a long list of URLs and I need to do HTTP requests for each of
these domains.

# -----------------------------------------------------------------
@urls = (
'http://www.yahoo.com',
'http://www.google.com',
'http://www.msn.com',
'http://www.altavista.com'
);

use LWP::UserAgent;
$ua = LWP::UserAgent->new;

foreach $url (@urls)
{
$req = HTTP::Request->new('GET', "$url");
$results = $ua->request($req)->as_string;

# then process $results
}
# -----------------------------------------------------------------

How do I multi-thread so that multiple URLs are http-requested at the
same time?

Any help would be appreciated.

Thank you



Jason Q.
 
Reply With Quote
 
 
 
 
Iain Chalmers
Guest
Posts: n/a
 
      12-03-2003
In article <(E-Mail Removed)>,
http://www.velocityreviews.com/forums/(E-Mail Removed) (Jason Quek) wrote:

> How do I multi-thread so that multiple URLs are http-requested at the
> same time?


See LWP:arallel - its all done for you (and works _very_ well, thanks
Marc!)

http://search.cpan.org/~marclang/Par...b/LWP/Parallel.
pm

(watch the line wrapping on that)

big

--
'When I first met Katho, she had a meat cleaver in one hand and
half a sheep in the other. "Come in", she says, "Hammo's not here.
I hope you like meat.' Sharkey in aus.moto
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments