in reply to Getting times (weeks, days, hours, minutes, seconds)

Here is another way... Simply, sum the minutes and seconds and use gmtime() to convert the total number of seconds to hours, minutes, seconds. This of course assumes some time delta from the epoch number of seconds(0) for each item. Which is fine in this case as we are measuring duration, not absolute date values.

The year and day of week, etc are all meaningless in this context so just throw them away. Leap seconds, leap years don't matter as long as we are talking about data like your example.

#!/usr/bin/perl -w use strict; my @times = qw( 5:21 8:01 5:37 7:19 5:46 7:44 6:43 7:17 8:02 6:50 7:54 + 8:44 ); my $total_minutes; my $total_seconds; foreach my $time (@times) { my ($m,$s) = split(':',$time); $total_minutes += $m; $total_seconds += $s; } my ($h,$m,$s) = (gmtime($total_minutes*60+$total_seconds))[2,1,0]; print "$h hours, $m minutes, $s seconds"; #1 hours, 25 minutes, 18 seconds
The list slice isn't necessary, but I like to line up the left hand side vars so that they are in the order that I use them later. my ($s,$m,$h) would be fine without the slice.