>> I have a line like this:
>>
>> $rststr = get("http://"; . $dst . "/request.htm" );
>>
>> Problem is that I have had this script hang due to the $dst site being
>> down.  Is there a way to do a time out?
>
> Consider using the core alarm() function, or using LWP::UserAgent (I'm
> guessing you're using LWP::Simple here, which is just a wrapper around
> LWP::UserAgent) and specifying the timeout attribute on that object.

Thanks.  Yes, using Simple.  Looking at this.

Can I do something as simple as this?

$rststr = "";
alarm(60); # set timer for 60 seconds
$rststr = get("http://"; . $dst . "/request.htm" ); # try to get my data
alarm(0); # turn off timer

If the get failed I just want $rststr empty or filled with what data
was received.  Or MUST I define an alarm condition?  I am also
thinking I must wrap this in eval?  This is on a linux server.  Thanks
again.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to