On Thu, Nov 29, 2001 at 03:16:04PM -0500, Ken Hammer wrote:
> Hi all,
> 
>  I have a script that goes out and "grabs"
> a specific HTML page. I then search through
> the page, gathering the info I want.
>  Sometimes, the site I'm hitting is either
> bogged down or unresponsive. I'd like to
> include a timing mechanism that basically
> says after 10 secs, quit trying to get
> the page and move on.
>  Some sample code:
> 
> 
>  my $url = "http://$host:$port/page";;
>  my $ua = LWP::UserAgent->new();
>  $ua->agent("Godzilla/v911 Mithril");
>  my $req = HTTP::Request->new(GET =>$url);
> 
>  $req->referer("http://nowhere.com";);
> 
> Loop until you reach 10 seconds {
> 
>  my $response = $ua->request($req);
>  my $content = $response->content();
> 
> }

our flag;
sub alarm_handler 
{
        set flag;
}       
        
set alarm to expire after 10 secs;
Loop indefinitely {
 exit if ($flag);
 my $response = $ua->request($req);
 my $content = $response->content();

}

As with the other reply that I made on this list, there is a race between alarm and
the loop. It could be so that the alarm expires before the loop starts on a heavily 
loaded
system. 
/kk

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to