in reply to Getting From here to an Array

Here's one way you could parse it. As for what you do with it after that, I don't know. I just dump it with Dumper so you can see the structure.

use strict; use warnings; my @records; <DATA> =~ /^Daily Listing of Reports/ or die "bad report input line 1\ +n"; <DATA> =~ /^GW Posted Date/ or die "bad report input line 2\n"; my $record = []; while (<DATA>) { chomp; push @$record, $_; if ( /^R[A-Z]\d{5}$/ ) { splice @{$record}, 2, $#{$record}-2, join ' ', @{$record}[ 2 .. $#{$record}-1 ]; push @records, $record; $record = []; } } use Data::Dumper; print Dumper \@records; __DATA__ Daily Listing of Reports GW Posted Date CRS Publication Date Title Text 01/14/2009 12/09/2008 China-U.S. Relations: Current Issues and Implications for U.S. Policy RL33877 01/14/2009 12/31/2008 Greenhouse Gas Emission Drivers: Population, Economic Development and Growth, and Energy Use RL33970 01/14/2009 12/30/2008 School Construction, Modernization, Renovation, and Repair Issues: 110th Congress RS22894 © Copyright GalleryWatch.com, Inc. (1999 - 2009), provided under licen +se. NO CLAIM TO ORIGINAL U.S. OR STATE GOVERNMENT WORKS
Between the mind which plans and the hands which build, there must be a mediator... and this mediator must be the heart.

Replies are listed 'Best First'.
Re^2: Getting From here to an Array
by jseager (Initiate) on Jan 17, 2009 at 21:34 UTC

    Thanks so much. The code you provide solved many of my questions. However it then opened up another dilemma. The line:  if ( /^R[A-Z]\d{5}$/ ) works great unless the text in question reads:

    Projections of FY2009 Federal SCHIP Allotments Under CHIPRA 2009

    If my "text" ends with a date then the subsequent lines all join until the code finds another string of text that also ends in a date. In this case both lines happen to end in 2009.

      The line: if ( /^R[A-Z]\d{5}$/ ) works great unless the text in question reads:

      I don't see the relevance of the example text you posted. That line is suppose to match the order number. He did make assumptions as to what the order number looked like, but that doesn't seem to be what you're questioning.

      Thanks. Yes, you're right. I made an assumption based on the data I saw. You are certainly free (and expected) to modify the code as necessary. Even better, learn from it and then write your own code. :-)

      Between the mind which plans and the hands which build, there must be a mediator... and this mediator must be the heart.