in reply to Print a previous to previous of a matching line
Anonymous Monk's suggestion is the right one, just a bit elliptic. Let's phrase this another way:
- You're going through the file a line at a time.
- If you see a line you might want (a "Query" line), you save it in a variable and keep reading lines.
- If you see a "hits" line that matches your criterion, the line you saved was one you want. Print it or stick it in an array for later, or...
- If you see a "hits" line and it doesn't match your criterion, then you don't want the "Query" you saw previously. Throw it away by setting the variable to "".
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Print a previous to previous of a matching line
by ag88 (Novice) on Oct 11, 2013 at 07:49 UTC |
In Section
Seekers of Perl Wisdom