use Time::HiRes qw( gettimeofday tv_interval ); my $start_time = [gettimeofday]; # work hard printf "hard work took %.2f seconds\n", tv_interval( $start_time );