open(IN, '<', $file) or die "Couldn't open $file for reading: $!\n\n"; my (@hdr, %stn, %seg); my ($lname); while () { if (/^H/ ... /[<\[]/) ## If it's a header line... { push(@hdr, $_); ## ...add it to @hdr next; } next if (/reclin/i); ## If it's a DISCO header, ignore; continue to ## next iteration ## Not a header, so must be data.... ( $lname = substr($_,1,16) ) =~ s/\s+//g; ( my $s = substr($_,17,8) ) =~ s/\s+//g; ( my $x = substr($_,45,8) ) =~ s/\s+//g; ( my $y = substr($_,53,8) ) =~ s/\s+//g; ( my $z = substr($_,61,5) ) =~ s/\s+//g; $stn{$s} = [ $x, $y, $z ]; ## HoA: Keys = Stn ID ## Value = Stn Coords #### $seg{$lname} = { 'header' => \@hdr, 'stations' => \%stn, }; #### __DATA__ 80-101 412 54175659N114551423W 635314260187896 6756 80-101 413 54175657N114551794W 635247260187870 6760 80-101 414 54175655N114552165W 635180260187843 6775 80-101 415 54175653N114552535W 635113360187817 6748 80-101 416 54175650N114552905W 635046560187790 6721 H CLIENT : ************* H PROSPECT : ************* H CONTRACTOR : CANJAY EXPLORATION LINE NAME : 80-103 H SURVEY CO. : CANJAY EXP. UNIQUE ID : ******* #### __DATA__ 80-101 412 54175659N114551423W 635314260187896 6756 80-101 413 54175657N114551794W 635247260187870 6760 80-101 414 54175655N114552165W 635180260187843 6775 80-101 415 54175653N114552535W 635113360187817 6748 80-101 416 54175650N114552905W 635046560187790 6721 80-103 224 54160602N114433190W 648117760157647 6774 80-103 225 54160602N114433561W 648050760157627 6769 80-103 226 54160602N114433931W 647983760157606 6763 80-103 227 54160602N114434302W 647916760157585 6758 80-103 228 54160603N114434672W 647849760157564 6753