my @times = ...; my %date_count; foreach my $time (@times) { my ($y,$m,$d,$h) = (localtime($time))[5,4,3,2]; $date_count{$y+1900}{$m+1}{$d}{$h}++; } ... #### use Time::Local qw( timelocal ); my @times = ...; my %date_count; foreach my $time (@times) { my ($y,$m,$d,$h) = (localtime($time))[5,4,3,2]; $date_count{timelocal(0,0,0,$d,$m,$y)}++; } ...