assuming the '@QUERY' and '@ENDQUERY' are prefixes that have to appear everywhere. This will only print the data lines, and the delimiter lines — not the junk inbetween.while(<>) { tr/\r//d; # get rid of the CR print if /^\@QUERY/ .. /^\@ENDQUERY/; }
The flipflop operator, .. in scalar context, is a particular one which has built in memory of its previous state. Its initial state is false. So it'll return true from the first time the expression on its left hand side returns true, and every time you'll test it after that, it'll still remain true, up to and including the first time the expression on its right hand side becomes true, since this start. After that, it'll return false again... and you can start again from the top.
If you really want to do it your way, try
in which the expression will evaluate to true from the first time '@QUERY' is encountered, up to the end of the current file.while(<>) { tr/\r//d; print if /^\@QUERY/ .. eof; }
In reply to Re: strip out lines until match
by bart
in thread strip out lines until match
by alienhuman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |