You probably have two problems which interact. First, you must parse the input file into blocks. Second, you must process each block with the regular expressions from the other files.

Lets address just the parsing problem. My code (with $/ = "THE_END\n") correctly parses your sample data. If that sample is accurate, the code will parse real data. If there is a problem, as you have guessed, it almost certainly has to do with whitespace at the end on the block.

Use a text editor on your copy of the sample data file. Verify that between the last data digit in one block and the first data digit of the next block we find "\nTHE_END\n" (and absolutely nothing else!). Do the same for live data. Check several pairs of blocks just to be sure. Let me know what happened.

If we passed the previous test, You are almost certainly parsing correctly, but have a problem with the processing. Again, the problem very likely has to do with whitespace. I really cannot offer any more help without having a real regex and a data block that you expect to match it.

Bill

In reply to Re^9: Write to multiple files according to multiple regex by BillKSmith
in thread Write to multiple files according to multiple regex by Foodeywo

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.