I tried the second solution with the fudge factor but it goes negative in less than an hour. I'll go back to the original suggestion and make sure the value is not negative before using it to sleep. Thanks again
#!/usr/bin/perl
use strict; # https://perlmonks.org/?node_id=11111868
use warnings;
use Time::HiRes qw( time sleep );
my $fudgefactor = 0.001;
while(1)
{
my $time = time;
my $nextsecond = int $time + 1;
my $interval = $nextsecond - $time - $fudgefactor;
$interval > 0 and sleep $interval;
1 while time < $nextsecond;
printf "%.6f\n", time;
}