Hey all, I have a report that has three different sections that I need to split up and then make spreadsheets out of. I need to pull data out of the report, from one point to another, three separate times. ex - The report has info for three different regions. The different areas of the report begin with the words "REGION" followed by a region number and name. The info for the particular region ends with a line containing the words "REGION TOTAL". What I need to do is collect the info between "REGION" and "REGION TOTAL" and save it into a separate array for later processing. I need to do this for each region in the report or three times... however you like to say it. I can succesfully test for and grab the line that begins with "REGION". How do I grab the info up to and including the "REGION TOTAL" line? Here is what I have so far:
#!/usr/local/bin/perl -w # # # #### use strict; #### # # # #### my $past_file = "pastinv.txt"; open(PFILE,"$past_file") || die "$past_file,$!"; my @pinv1 = <PFILE>; close PFILE || die "$past_file,$!"; #### # # # # #### my @tmp_pinv = "@pinv1"; my $count = @pinv1; my ($i,@sue,@mike,@steve); for ($i = 0; $i<= $count -1; $i++) { my $line = shift(@pinv1); chomp $line; if ( $line =~ /Region/ ) { $line =~ s/\s+/ /g; my($region,$reg_num,@name) = split(/ /,$line); if ( $reg_num =~ /(7A)/ ) { unshift(@steve,$region,$reg_num,@name); print "@steve\n"; #region_info(\@steve,\@tmp_pinv); }elsif ( $reg_num == 7 ) { unshift(@sue,$region,$reg_num,@name); print "@sue\n"; }elsif ( $reg_num == 8 ) { unshift(@mike,$region,$reg_num,@name); print "@mike\n"; } }else{ next; } }
This is the code I'm using to grab lines that have the region numbers in them. The line that has the sub region_info was one of my many attempts at accomplishing what I'm trying to do here. If anyone can help me out I would greatly appreciate it. Thanks in advance, Bradley Where ever there is confusion to be had... I'll be there.

In reply to Report parsing by Dalin

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.