schnibitz has asked for the wisdom of the Perl Monks concerning the following question:
use HTTP::Lite; use threads; my $a = 0; my $i = 0; sub request { print "trying to open up $address\n", scalar(localtime), "\n"; $http = new HTTP::Lite; $req = $http->request("$address") or die "Unable to get document: $!"; $i++; my $content = $http->body(); print " Done with request for $address\n"; my $search_variable = "test"; if ( $content =~ m/$search_variable/) { $a++ while ($content =~ m/$search_variable/g); } print " Finished searching $address for $search_variable", +scalar(localtime), "\n"; } my @addresses = ( 'http://www.website1.com', 'http://www.website2.com', . . . 'http://www.website50.com' ); #my $URLResult = $Result->Url; my @threads; foreach $address(@addresses) { my $thread = threads->create(\&request); push(@threads, $thread); } } foreach (@threads) { $_->join(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Threaded Web requests
by rcaputo (Chaplain) on Jan 02, 2010 at 23:05 UTC | |
|
Re: Threaded Web requests
by BrowserUk (Patriarch) on Jan 03, 2010 at 00:25 UTC | |
by schnibitz (Novice) on Jan 03, 2010 at 06:36 UTC |