use Data::Dumper; my %msg_rate = ('1', '00:00:00,284', '2', '00:00:00,462', '3', '01:01:00,462', '4', '00:02:00,462', +'5', '01:03:00,462'); my %count_per_min; while( my ($key1, $val1) = each(%msg_rate) ) { my ($hh1,$mm1,$ssms1) = split(/\:/,$val1); $count_per_min{"$hh1:$mm1"}++ } print Dumper \%count_per_min;