The information you provide about your input data and the sample data structure you show are inconsistent so the following sample code may not print what you want, but the parsing should at least get you headed in a useful direction:

#!/usr/bin/perl use strict; use warnings; use 5.010; my %recs; while (<DATA>) { my ($time, $mode, $value) = /(\d\d:\d\d:\d\d)\.\d{3} .*? (?: (Pending|Gap) (?:\sdetect\son\s | =)? ([\d.:]+) ) /x; next if !defined $time || !defined $mode; if ($mode eq 'Pending') { $recs{$time}{Pending} = $value; next; } ++$recs{$time}{Gaps}{$value}; } for my $rec (map {$recs{$_}} sort keys %recs) { my $pend = "Pending=$rec->{Pending}\n"; print join $pend, map {"Gap detect $_ "} sort keys %{$rec->{Gaps}} if exists $rec->{Gaps}; print $pend; } __DATA__ 2011-04-03 09:37:12.129 (INFO, ICELineHandler.cpp:339) Product Def Mar +ketID 90120253, Symbol 'BRN FMU0012_OMCA0000118502081312' 2011-04-09 21:32:15.525 3509,3523: Gap detect on 233.156.208.41:20041 +from 2746318 to 2746373, moving to next message 2011-04-09 21:32:15.585 3509,3523: Gap detect on 233.156.208.41:20041 +from 2746420 to 2746475, moving to next message 2011-04-09 21:32:15.639 3509,3522: Received data on ConnectionICE-Opti +ons. Pending=214044. 2011-04-03 09:37:12.129 (INFO, ICELineHandler.cpp:339) Product Def Mar +ketID 90120253, Symbol 'BRN FMU0012_OMCA0000118502081312'

Prints:

Gap detect 233.156.208.41:20041 Pending=214044.
True laziness is hard work

In reply to Re: Help with hash of arrays from file by GrandFather
in thread Help with hash of arrays from file by jb60606

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.