I'd be tempted to use
while(<>) { tr/\r//d; # get rid of the CR print if /^\@QUERY/ .. /^\@ENDQUERY/; }
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.

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

while(<>) { tr/\r//d; print if /^\@QUERY/ .. eof; }
in which the expression will evaluate to true from the first time '@QUERY' is encountered, up to the end of the current file.

In reply to Re: strip out lines until match by bart
in thread strip out lines until match by alienhuman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.