use strict; use warnings; use Benchmark; my $start_time = new Benchmark; sleep (2); # Do stuff my $end_time = new Benchmark; my $difference = timediff($end_time, $start_time); my $seconds = $difference->[0]; my $hours = int ($seconds / 3600); my $mins = int (($seconds %= 3600) / 60); $seconds -= $mins * 60; print ("It took $hours hours, $mins minutes and $seconds seconds.\n");