Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: How move on to next ip if no connection got established?

by Henri Icarus (Beadle)
on Jun 04, 2001 at 22:59 UTC ( [id://85555] : note . print w/replies, xml ) Need Help??


in reply to How move on to next ip if no connection got established?

As long as you are on a unix system that handles signals you can use this:
$seconds_allowed_to_do_task = 5; foreach (@list_of_things_to_do) { eval { local $SIG{ALRM} = sub { die "dead"}; alarm $seconds_allowed_to_do_task; &doTask($_); alarm 0; }; }
The eval loop get's killed by the "die" after the alarm goes off (if it does). So just put your IP address in the list, and make doTask be the function that does your http connection. -Henri