>> 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 > > More or less, yes--have you tried it? Also, do consider using 'my' to > declare your variables. > >> 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. >> > > Yes, you need to use alarm with LWP::Simple because, well, it's simple. > It isn't very flexible because the API was designed to make it easy to > use. This is the tradeoff of using a ::Simple API--it's not as flexible > as something more complex. This is one of the fundamental tradeoffs of > programming.
I did this. Snippet from larger code: eval { $rststr = ""; local $SIG{ALRM} = sub { die "get timeout" }; alarm(30); $rststr = get("http://" . $dst . "/request.htm" ); # try to get my data alarm(0); } ; It 'appears' to work. Does it look right? One error I did receive. If I did this 'eval { ... }' instead of this 'eval { ... } ;' I would get error about missing semicolon. Does eval expect more arguments or something that it requires a semicolon? Or is it because eval returns a result? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/