in reply to Simplifying Timediff Output from Seconds to Hours and Minute

The documentation for Benchmark notes:

The data is stored as a list of values from the time and times functions:

($real, $user, $system, $children_user, $children_system, $iters)

in seconds for the whole loop (not divided by the number of rounds).

so the first element of the array referenced by a benchmark object is a time in seconds. The following code extracts the time in seconds and converts it to hours, minutes and seconds in a fairly nieve fashion:

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");

DWIM is Perl's answer to Gödel