my %TH; sub report { $TH{$_[0]} += tv_interval($TH); $TH = [gettimeofday]; } ... print "$_: $TH{$_}\n" for keys %TH;