use Time::HiRes qw( usleep gettimeofday ); while ( 1 ) { usleep 1_000_000 - (gettimeofday)[1]; &do_stuff(); } sub do_stuff { print Time::HiRes::time . "\n"; 1; }