Maybe this'll be helpful. ) my $time_rx = qr/(?<timestamp> (?<hour> \d{2} ) (?: :\d{2} ){2} ) /x;
my $cell_record_rx = qr/CELL \s+ (?<cell_number> \d+) \s+ (?<cell_info> [^,]+) /x; my $records_ref; my $record_ts; while (<>) { if ($record_ts) { # looking for record data of this particular timestamp if (/$cell_record_rx/) { ++$records_ref->{$record_ts}{ $+{cell_number} }{ $+{cell_info} }; undef $record_ts; } } else { #scanning for next valid record if (/$time_rx/ && $+{hour} >= 17 && $+{hour} <= 21) { $record_ts = $+{timestamp}; } } } -- iD 2011/10/18 Chris Stinemetz <chrisstinem...@gmail.com> > On Mon, Oct 17, 2011 at 10:57 PM, Leo Susanto <leosusa...@gmail.com> > wrote: > > From looking at the regex > > > >> if ($line =~ > /17|18|19|20|21+:(\d+):(\d+)+\n+\n+CELL\s+(\d+)\s+(.+?),.+?HEH/){ > > > > against the data > > > >> 10/17/11 18:25:20 #578030 > >> > >> 25 REPT:CELL 221 CDM 2, CRC, HEH > >> SUPPRESSED MSGS: 0 > >> ERROR TYPE: ONEBTS MODULAR CELL ERROR > >> SET: MLG BANDWIDTH CHANGE > >> MLG 1 BANDWIDTH = 1536 > > > > I would assume $1 and $2 wouldn't match to anything plus $5 doesn't > exist. > > > > Could you please let us know which part of the data you want to extract? > > > > Fill in the blanks > > $1= > > $2= > > $3= > > $4= > > $5= > > > > Thanks everyone. I hope this clarifies what I am trying to match. For > example with this input: > > 10/17/11 18:25:20 #578030 > > 25 REPT:CELL 221 CDM 2, CRC, HEH > SUPPRESSED MSGS: 0 > ERROR TYPE: ONEBTS MODULAR CELL ERROR > SET: MLG BANDWIDTH CHANGE > MLG 1 BANDWIDTH = 1536 > > > $1= Match the time stamp Hour:Min:Sec only if the hour is >= 17 and hour <= > 21 > $2= capture CELL number > $3= capture the information after the CELL number (and before the first > comma) > > Thank you, > > Chris > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > >