First, you don't show the code that "checks the website". Maybe something like this will work?
use HTTP::Request::Common qw(GET); my $url_target = "some_url_to_check"; # like: http//x.y.z.com while (my $url = GET $url_target) { # $url contains some text here that you process... # this means that the GET function succeeded. # the GET is a "blocking" dunction and waits until it gets a # "yes" or "no" answer; sleep(60); #We don't know how long the last "get" took #but we are going to wait 60 secs before we #try it again... } else { die "Opps there is a problem"; # this will happen maybe about 1/1000 attempts } ; I would recommend some sort of control on the number of trips through the "else" clause to prevent program infinite loops. #perhaps like this: use constant MAX_RETRY => 5; my $retries =0; while ( my $url = GET $url_target) { #do something here..as above.... $retries =0; sleep(60); } else { $retries++; if ($reties > MAX_RETRY) { die "maximum tries exceeded"; } next; #try again... } ;
In reply to Re: Help to infinite loop
by Marshall
in thread Help to infinite loop
by Mik0r
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |