in reply to Re^3: How to print certain lines out of a text file.
in thread How to print certain lines out of a text file.
By way of a better explanation, your solution should be something called a "state machine", where at any given time your program is in one of a finite set of "states" (it seems like two states will suffice here). Whether or not you print a given line depends on what state you're in, and there are certain lines that will cause a change of state. Make sense? Here's pseudo-code, which is pretty close to a perl solution:
That should do what you want. Let us know if you have trouble turning that into perl code. (It shouldn't be hard.)initial state is "0"; while there's a line that you've read from the file { set state to "1" if the current line contains "HW/OS/Client" print the current line if the current state is "1" (true) set state to "0" if the current line is blank (contains only white-sp +ace) }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: How to print certain lines out of a text file.
by sawdustar (Novice) on Jul 31, 2010 at 22:48 UTC | |
by graff (Chancellor) on Jul 31, 2010 at 23:08 UTC |