You can outright replace any logic that goes like:
while(<FILE>) { ...
with this:
for (split "(?<=\Q$/\E)", $contents_of_FILE) { ...
and it does exactly the same thing.

Which just means: split the content of the file on the zero-width positive lookbehind assertion of $/ (the input record separator). This is subtley different from just splitting on $/ (or, more safely, splitting on \Q$/\E), in that splitting on $/, itself, removes $/ from the output of the split... whereas splitting on the zero-width positive lookbehind assertion leaves it in. (This is because what is being splitted on is the empty string following each occurence of $/, so that is the thing that gets removed).

Anyway, this may not be the best way to deal with the situation of your problem, but it is the most general solution for dropping in a replacement of a <FILE> loop with some sort of loop over the contents of FILE.


------------
:Wq
Not an editor command: Wq

In reply to Re: addn'l help with parsing here doc by etcshadow
in thread addn'l help with parsing here doc by smackdab

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.