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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting From here to an Array
by jseager (Initiate) on Jan 17, 2009 at 21:34 UTC | |
by ikegami (Patriarch) on Jan 17, 2009 at 23:49 UTC | |
by jdporter (Paladin) on Jan 18, 2009 at 03:25 UTC |