T
tower.grv
Hello.
I want my Perl script execute some code in the begining of each
second.
I have code
----------------------------------------------------
#!/usr/bin/perl -w
my $thistime=time();
while(1){
while(time()-$thistime<1) {my $a=1;}
$thistime=time();
print $thistime."\n";
#some more code
}
----------------------------------------------------
This code works but it takes a lot of CPU resources.
sleep(1) is not good for me. Usually it is needed to sleep less then
second.
Is it possible to replace line
while(time()-$thistime<1) {my $a=1;}
with better code?
I want my Perl script execute some code in the begining of each
second.
I have code
----------------------------------------------------
#!/usr/bin/perl -w
my $thistime=time();
while(1){
while(time()-$thistime<1) {my $a=1;}
$thistime=time();
print $thistime."\n";
#some more code
}
----------------------------------------------------
This code works but it takes a lot of CPU resources.
sleep(1) is not good for me. Usually it is needed to sleep less then
second.
Is it possible to replace line
while(time()-$thistime<1) {my $a=1;}
with better code?