This part of your spec is confusing (at least to me)...
  1. If cat is followed by dog in the preceding (next?) line, I want to delete both lines.
  2. But if dog is followed by cat, I want to keep both the lines.
    What the purpose of this extra condition?
In this sequence, does line 3 being "cat" somehow overrule, Rule #1 and keep line #2, dog and even perhaps line #1 in the output?
1 cat 2 dog 3 cat
Rule #1 says this should be "cat" (dog cannot follow cat):
3 cat
But Rule #2, seems to indicate that sometimes cat can indeed follow dog - maybe the confluence or Rule 1 and Rule 2 causes "1 cat" to be deleted, but somehow "2 dog" is saved from deletion by Rule #2? How this would work is certainly not clear to me.:
2 dog 3 cat
Or maybe even no changes at all happen due to conflicting rules?!
1 cat 2 dog 3 cat
The English and code examples are not sufficient for me to understand what to code that will exactly solve your problem. The requirements are just not clear to me.

Please correct the English and elaborate on the examples.


In reply to Re: If line is followed by line, delete both lines by Marshall
in thread If line is followed by line, delete both lines by Ganesh Bharadwaj1

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.