#!/usr/bin/perl use LWP::Simple; print "Content-type: text/html\n\n<html><body bgcolor=white>\n"; local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required eval { alarm 4; $content = get("http://select.worldpay.com/wcc/info?op=rates&instI +d=36128"); alarm 0; }; if ($@) { die unless $@ eq "alarm\n"; # propagate unexpected errors # timed out print "timed out<BR>"; } else { # didn't print "succeeded<BR>"; } if($content) { print $content; } else { print "Durrr"; }
It's still hanging.
I haven't really understood how to use SIGALARM - I am just coding-by-numbers at the moment hoping that understanding will dawn.
In reply to Re: Re: How do I tell if a remote site is up?
by Elliott
in thread How do I tell if a remote site is up?
by Elliott
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |