help on LWP::Parallel
jliang888_at_yahoo.com
Date: 03/08/05
- Next message: Bill Corden: "New to Perl"
- Previous message: Joe Smith: "Re: environment inheritance.."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 8 Mar 2005 11:37:27 -0800
Is there anyway can make my script continue to run? If I just run 1st
and 2nd or 1st and 3rd in the request list, the script won't be
terminated, but it will be broken when list contains both 2nd and 3rd
URLs.
#!/usr/bin/perl -w
require LWP::Parallel::UserAgent;
use HTTP::Request;
# display tons of debugging messages. See 'perldoc LWP::Debug'
#use LWP::Debug qw(+);
# shortcut for demo URLs
my $reqs = [
HTTP::Request->new('GET', 'http://www.yahoo.com'),
HTTP::Request->new('GET', 'http://www.oceanestatesa.com'),
HTTP::Request->new('GET',
'http://www.oceanstatenautical.com'),
];
my $pua = LWP::Parallel::UserAgent->new();
$pua->in_order (1); # handle requests in order of
registration
$pua->duplicates(0); # ignore duplicates
$pua->timeout (2); # in seconds
$pua->redirect (1); # follow redirects
foreach my $req (@$reqs) {
print "Registering '".$req->url."'\n";
if ( my $res = $pua->register ($req) ) {
print STDERR $res->error_as_HTML;
}
}
my $entries = $pua->wait();
foreach (keys %$entries) {
my $res = $entries->{$_}->response;
print "Answer for '",$res->request->url, "' was \t",
$res->code,": ",
$res->message,"\n";
}
Thnaks.
J.
- Next message: Bill Corden: "New to Perl"
- Previous message: Joe Smith: "Re: environment inheritance.."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]