in reply to Help with hash of arrays from file

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