use Time::HiRes qw( gettimeofday ); my $stime = gettimeofday; . . . print "Time taken: ",gettimeofday - $stime," seconds\n";