You didn't give us source data, only the end result, so I had to extrapolate the source data. Here's some code that should hopefully do more or less what you want - expanding it further is left up to you.

use Time::Local; use strict; use warnings; my $word = 'bravo'; my $year = (localtime())[5] + 1900; my @months = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; my %months; $months{$months[$_]} = $_ for 0..11; my ($ts, $min, $max, %results, $d1, $d2); while (<DATA>) { chomp; ### Calculate timestamp for start of given minute if (m/(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(.*)/) { $ts = timelocal(0, $4, $3, $2, $months{$1}, $year); ### Count instances of word for (split /\s+/, $6) { $results{$ts}++ if uc $_ eq uc $word; } } } ### Sort results by timestamp for $ts (sort { $a <=> $b } keys %results) { ### Start date / time (00) $d1 = [localtime($ts)]; $d1 = $months[$d1->[4]] . sprintf(' %02d %02d:%02d:%02d', $d1->[3], $d1->[2], $d1->[1], $d1->[0]); ### End date / time (59) $d2 = [localtime($ts + 59)]; $d2 = $months[$d2->[4]] . sprintf(' %02d %02d:%02d:%02d', $d2->[3], $d2->[2], $d2->[1], $d2->[0]); ### If you want first, second, third, etc, you'll have ### to implement that part yourself print "$d1 $d2 $results{$ts} matches\n"; } __DATA__ Dec 5 09:02:01 alpha bravo charlie Dec 5 09:02:02 bravo Dec 17 17:34:02 bravo charlie tango

In reply to Re: Problems in dates and time additions by one minute by TJPride
in thread Problems in dates and time additions by one minute by Survivor

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.