Well, I am no genius, but something like this should get you started. You'll
have to strip off the first line though for this to work.

#!/usr/local/bin/perl -w

use Data::Dumper;

open( INPUT, "landuse_filenames.txt" );
while( <INPUT> ) {
        chomp;
        ( $FILE_NAME, $USGS_QD_ID, $QUAD_NAME, $ST_NAME1, $ST_NAME2,
$ST_NAME3, $ST_NAME4, $DATE_REV, $DATE_PUB ) = split( /\t/ );
        $landhashes[$cnt++] = { file_name => $FILE_NAME, usgs_qd_id =>
$USGS_QD_ID, quad_name => $QUAD_NAME, st_name1 => $ST_NAME1, st_name2 =>
$ST_NAME2, st_name3 => $ST_NAME3, st_name4 => $ST_NAME4, date_rev =>
$DATE_REV, date_pub => $DATE_PUB };
}
close( INPUT );

print Dumper( \@landhashes );


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 05, 2002 2:48 PM
To: [EMAIL PROTECTED]
Subject: parse file into hash



Hello,
    I am new with perl and was hoping to get some direction.

I am attempting to parse a the attached .txt file.

i need to be able to access the information by unique keys, QUAD_NAME and
USGS_QD_ID. Also, I want to be able to do a somewhat less exact access byt
ST_NAME.

I was thinking that I would use a hash of arrays.  any suggestions on
parsing the file?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to