How about:
while (1) {
my $start = time;
# do what you need to do...
my $end = 5 - (time - $start);
sleep $end if $end > 0;
}
James
On Thursday, October 17, 2002, at 07:52 PM, Greg Oliver wrote:
I am writing a program that will do a certain function every 5
seconds. Currently, I am testing the modulus of time() / 5 to do the
function in a tight loop, but that seems pretty sloppy to me.
Unfortunately, I do not know of any other ways.
I have looked through all of the Time:: modules on CPAN.
The process I am executing takes ~1 second to run, so after I have the
script sleep(3) to cut down on the resources. Is there something
simple I am missing here that I could use to do what i want?
Thanks,
Greg
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]