use strict; use warnings; my @times = ( '13:45:23', '14:12:43', ); my $d = 0; # day my $h = 0; # hour my $m = 0; # min my $s = 0; # sec foreach my $time (@times) {   my ($hour, $min, $sec) = split /:/, $time;   $s += $hour * 3600 + $min * 60 + $sec; } $s >= 86400 and $d = sprintf('%i',$s / 86400) and $s = $s % 86400; $s >= 3600  and $h = sprintf('%i',$s / 3600)  and $s = $s % 3600; $s >= 60    and $m = sprintf('%i',$s / 60)    and $s = $s % 60; print "${d}d ${h}h ${m}m ${s}s\n";