in reply to read multi lines of a file in perl
You might also consider the flip-flop operator (see Flipin good, or a total flop?)
In your problem, the code would look something like:
while(<WORDLIST>) { if( /^process/ .. /end process/ ) { #recognize and skip first delimiter next if /^process/; #recognize and skip end delimiter next if /end process/; # do something with the middle. print; } }
This does have the advantage that it restarts if you hit another line starting with process. Obviously, you can also do something special with the start and end points.
Of course, if you don't need to know when the data starts and stops, you could just do
while(<WORDLIST>) { next if /^process/ or /^end process/; print; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: read multi lines of a file in perl
by johngg (Canon) on Nov 05, 2008 at 16:02 UTC | |
by gwadej (Chaplain) on Nov 05, 2008 at 17:39 UTC |