in reply to How to make a time-out with LWP::Simple
I am not sure how you could catch a timeout set in UserAgent, but wrapping your call in an eval, with an alarm, would
probably fit your needs.
$SIG{ALRM} = sub { die q{timeout} }; URL: foreach my $url ( @urls ) { alarm( 2 ); # amount of time allowed for call. eval { my $page = get( $url ); # LWP::Simple call }; if ( $@ =~ /^timeout/ ) { print qq{Skipping this one, timed out.\n}; next URL; } # Do something with successful call. }
Wonko
|
|---|