Do you want to display the statistics at different levels of granularity (by year, by month, by day or by hour), or only by hour? If you are after "only hour", then I'd generate a single level hash using "$dt->year$dt->month$dt->day$dt->hour" as the key. If you want to access the stats at multiple levels I'd do something like:

use warnings; use strict; use Date::EzDate; use Data::Dumper; my @times = qw( 1176992127 1177011950 1177035464 1177059040 1177063718 + 1177074117 1177100432 1177135347 1177165344 1177193537 1177202407 11 +77222982 1177224344 1177271548 1177280164 1177290568 1177320406 11773 +69446 1177392779 1177418018 1177424739 1177450967 1177459364 11774883 +49 1177506719 1177533725 1177544267 1177554850 1177596791 ); my %date_count; foreach my $time (@times) { my $dt = Date::EzDate->new ($time); $date_count{$dt->{year}}++; $date_count{"$dt->{year}/$dt->{monthnum}"}++; $date_count{"$dt->{year}/$dt->{monthnum}/$dt->{dayofmonth}"}++; $date_count{"$dt->{year}/$dt->{monthnum}/$dt->{dayofmonth} $dt->{h +our}"}++; } print "Year hits:\n", join ("\n", map {"$_ ($date_count{$_})"} sort grep {/^\d{4}$/} key +s %date_count), "\n"; print "Day hits:\n", join ("\n", map {"$_ ($date_count{$_})"} sort grep {m!^\d{4}/\d\d/ +\d\d$!} keys %date_count), "\n";

Prints:

Year hits: 2007 (29) Day hits: 2007/03/20 (5) 2007/03/21 (3) 2007/03/22 (5) 2007/03/23 (4) 2007/03/24 (2) 2007/03/25 (5) 2007/03/26 (4) 2007/03/27 (1)

DWIM is Perl's answer to Gödel

In reply to Re: Split date ranges/chunks based on Unix epoch time? by GrandFather
in thread Split date ranges/chunks based on Unix epoch time? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.