in reply to Help parsing badly constructed logfiles
I don't suppose fixing whatever's creating those logfiles is an option?
Here's what I might do: remember the previously-read line, and match your search term against both the current line and the concatenation of the previous and current line. Off the top of my head (completely untested):
my $previous = ""; while(defined(my $line = <>)) { chomp $line; ($previous . $line) =~ m/$pattern/ and say $line; $previous = $line; }
(This isn't perfect, obviously; it'll also print lines where the previous line just so happened to match, even though there's no match across the line boundary. But it should get you started.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help parsing badly constructed logfiles
by Amblikai (Scribe) on Jul 13, 2014 at 17:14 UTC |