in reply to Pimp My RegEx
I'm trying to understand the rationale behind your regex. Don't you want something more like
? If so, then it I would process the file line-wise, and count only those lines that begin with your date pattern.my $parse_log_entry = qr/^($dateRegex.*?)(?=(?:^$dateRegex|\z))/ms;
Or, if you need to do more than just counting, then something along the lines of
my $current; while ( <DATA> ) { if ( /^$dateRegex/ ) { process( $current ) if defined $current; $current = $_; } else { $current .= $_; } } process( $current ) if defined $current;
Update: Added the more extended second alternative.
Update 2: Fixed bug (last line of code was missing).
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pimp My RegEx
by heathen (Acolyte) on May 31, 2005 at 18:46 UTC | |
by tlm (Prior) on May 31, 2005 at 18:57 UTC | |
by heathen (Acolyte) on May 31, 2005 at 20:19 UTC |