in reply to Re: How to make a time-out with LWP::Simple
in thread How to make a time-out with LWP::Simple

Okay, I went to that and I now know how to set a timeout. The question is now, how do I check for it? Rather than just timing out and moving on, I need to print a message stating it skipped it to browser.
use CGI qw/:standard/; use LWP::Simple qw(!head $ua); use LWP::UserAgent; use HTML::LinkExtor; use URI::URL; my $ua = LWP::UserAgent->new; $ua->timeout(10); my $p = HTML::LinkExtor->new; my $res = $ua->request(HTTP::Request->new(GET => $url), sub {$p->parse($_[0])}); #### INSERT TIMEOUT CHECK HERE if (timeout) { print "This url timed out"; } if ($res->status_line =~ /NOT FOUND/i) { print "NOT FOUND!"; }