in reply to loop control
i.e.: ntimes / 12hours
= ntimes / 12 * 3600seconds
= ntimes / 43200seconds
period = 1 / frequency
therefore period = ( 43200 / n )seconds
Using this little gem of basic mathematics, you can then proceed to recode your script:
use IO::Socket; my $sock = new IO::Socket::INET("$remote_server:43") || die $!; my $n = 5; # do this 5 times every 12 hours while (1) # loop forever { print $sock "$data\r\n"; my @output = <$sock>; $output = join('', @output); if ($output =~ /$no_match/gi) { &true; } else { &false; } # sleep for the PERIOD sleep( int(43200 / $n) ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: loop control
by jhourcle (Prior) on Dec 02, 2005 at 12:55 UTC | |
by webshark (Acolyte) on Dec 02, 2005 at 13:50 UTC | |
by webshark (Acolyte) on Dec 06, 2005 at 11:13 UTC | |
by webshark (Acolyte) on Dec 10, 2005 at 12:41 UTC |