Are you streaming the file? Are you slurping it into an array? Are you slurping it into a string? The answer for your question depends strongly on how you are dealing with the file. Please read How do I post a question effectively? and post your code and sample input so we can understand context. For example, if you have slurped it into a string and wish to remove all text between two tags but not the tags themselves, you can use a regular expression:

$string =~ /\/patt1\/.*?\/patt2\///sg;

If you are streaming, you can use a flag to monitor whether you are inside a comment or not.


In reply to Re: Remove multiple lines between two patterns by kennethk
in thread Remove multiple lines between two patterns by jcvivar

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.