I need to fetch a page into a string, and timout if it takes to long.
Here is my attempt.
my $ua = LWP::UserAgent->new;
$ua->timeout(1);
my $url = $urls{$server_num};
my $return = $ua->request(GET $url)->as_string;
This doesn't work. It fetches the page fine, but it doesn't respect
the timeout. If I try to fetch a page from a non-existant server,
it still tries for 30 seconds or so, then returns a string containing
an error message. How do I get the code to use a timout, and what
will it return if the timout is triggered?
Thanks
Matt