The usual mantra at this point is "what have you tried". My guess is you haven't tried anything at all. In fact I bet you haven't even thought hard about it (go ahead, prove me wrong - I'd love to be wrong about this). So lets map the problem into a different domain and see where it gets us:

Consider how you would do it if the lines were instead boxes on a conveyor belt and you had the same problem - remove the 10 boxes that have just gone past if the 10th has a red X on it. If you are sitting right at the end of the belt where the boxes fall off into the hopper of doom you're stuffed. So move your seat along the belt 10 boxes in the direction they are coming from. Now when the red X'd box comes along you have the 10 boxes where you can get at em and remove them from the belt before the fall into the hopper.

Now all you've got to do is figure out how to translate that into Perl. I'll let you think about it a while before giving further hints. ;)


True laziness is hard work

In reply to Re: Delete 10 lines before matched line by GrandFather
in thread Delete 10 lines before matched line by briggs

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.