I have a large report that I need to extract data from. The report can be broken down into records, with the start of each one looking similar to what is below:

REPORT HEADER ISCDAYRECAP-001 ISC001 ISC RECAP REPORT FOR STORE: 001 + PAGE: 00 1 XTNDED MRKDWN F +OR STORE: 12.00 R U N DEPT: GROCERY POST DATE: 07 +/14/2011 DATE/TIME: 07/14/2011 21:11:05 EXTEND + MRKDWN REASON EXT. MRKDWN

I am using the following code to split the file out into the separate stores, but it splits out into two elements, with element 0 of the array being empty, and everything else within element 1:

#!/usr/bin/perl -w use strict; open my $IN,"<","QISC001" or die "Can not open QISC001: $!\n"; my @records; my $data = do{ local $/; <$IN>; }; @records = split m|(?<=\n)(?=REPORT HEADER ISCDAYRECAP-\d{3})|, $data; close $IN;

One thing that I noticed is that when viewing the input file in vi (I am doing this on a HP-UX system), there is a ^L character at the start of each store, with the exception of the first one, so my guess is that the first part of the regex is incorrect. As always, suggestions/hints are welcome.


TStanley
--------
People sleep peaceably in their beds at night only because rough men stand ready to do violence on their behalf. -- George Orwell

In reply to Problem with a regex? by TStanley

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.