Kyle R . Burton on Wed, 29 Nov 2000 09:12:21 -0500 (EST) |
> I have a Perl script accessing headlines from abc. Works great > but sometimes abc is not responding very nicely. Scripts hangs, not > all the time, just occasionally on: > > $raw_html_page=get "http://abcnews.go.com/"; > > Is there a way I can tell this thing to only wait for a reasonable amount of > time then abandon the attempt to contact the site? Use a sigalarm? This is coopted from the perlfunc manpage entry for alarm. eval { local $SIG{ALRM} = sub { die "alarm\n"; }; alarm 2; $raw_html_page=get "http://abcnews.go.com/"; alarm 0; }; if($@) { die unless $@ eq "alarm\n"; } k -- ------------------------------------------------------------------------------ "From a certain point onward there is no longer any turning back. That is the point that must be reached." -- Kafka mortis@voicenet.com http://www.voicenet.com/~mortis ------------------------------------------------------------------------------ **Majordomo list services provided by PANIX <URL:http://www.panix.com>** **To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|