in reply to Survey file parsing

A variant of samtregars's idea, all header lines look like they have a colon at offset 17 except the column headers which start with ' <' so

while ( <IN> ) { chomp; if ( substr( $_, 17, 1 ) eq ':' or /^ </ ) { # we are in the header } else { # now we are in the data } }

might work for you.

Cheers,

JohnGG

Update: Whoops, noticed that the column header lines actually start with ' <', corrected above

Replies are listed 'Best First'.
Re^2: Survey file parsing
by YYCseismic (Beadle) on Jun 27, 2008 at 19:42 UTC

    Okay. But here's yet another version of a header block:

    H--SEISMIC SURVEY DATA--SEG P1--test + LINE : ************** JOB NO. : ********* + CLIENT : ********************* + PROSPECT : **************** + CONTRACTOR : GEO STRATA RESOURCES INC. + FILENAME : ********* DATE : SEP 20, 2006 + PROJECTION : U.T.M. , S.F.=0.99960, NAD27, Clarke 1866 + ORIGIN : UTM ZONE 12 REF. MER. : 111.0000W + 0.99960000 DBS VERS. : ATS 2.6 + UNITS : GEOGRAPHICS: D.MS - COORD.: DECIMETERS - ELEV.: DECIMET +ERS SURVEYOR : MERCEDES SURVEYS COMPUTED BY : CAPELLA + KILOMETERS, LINE: 2.01 GROUP INTERVAL : 12.00 METER +S INTERPOLATED: ELEVATION = ^ ; HORIZONTAL = # ; BOTH = * + REM: SURVEY BY RTK GPS + + + + + + [ LINE ][ POINT ][ LAT ][ LONG ][ EAST ][ NORTH][ELE] *[ +COMMENT ]

    The lines are padded with white space, but that's no problem. However, not all lines are always used. I don't need to keep blank lines, nor the very last line(s) that start with '<' or '['.

Re^2: Survey file parsing
by YYCseismic (Beadle) on Jun 27, 2008 at 22:06 UTC

    I did try that one out, and then I discovered the solution I'm using (at least for now) in chapter 6 of the Perl Cookbook, 2nd Edition. Thanks though; your technique generally worked.