In the unlikely case that this is a problem, it's fairly straightforward to switch ...
I think we are not so far apart on this.

Switching involves abandoning one approach to solving the problem (and I might more clearly have expressed the idea that 'this approach' meant 'read the entire file to a string, operate on the string, and write the string back to a file') for a significantly different approach, perhaps one of those outlined in the balance of your reply. This is what I mean when I write that the approach does not scale well.

I agree that, given what one can divine about the OPer's data from the OP, the problem is not likely to arise. In fact, I would go further and say that, in my experience, problems like this never happen – until they happen, and then you have to go back and change a bunch of stuff and re-test everything; which, while straightforward, still costs time, effort and risk; hence, the caution about lack of scalability.


In reply to Re^4: Help with multiple line regex subsitution by AnomalousMonk
in thread Help with multiple line regex subsitution by gator456

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.