http://qs321.pair.com?node_id=684197


in reply to Re: Data Structures
in thread Data Structures

As I'm rather new to this kind of thing, I didn't realize that parallel data structures might not be a good idea. What you say makes sense, though.

I think I'm more inclined to go with your second option:

my @line = ( [ ## $line[ 0 ] [ xxx.xxx, yyy.yyy, zzz.zzz ], ## $line[0][0] (station 0) [ xxx.xxx, yyy.yyy, zzz.zzz ], ## (station 1) [ xxx.xxx, yyy.yyy, zzz.zzz ], ... ], [ ## Line[ 1 ] [ xxx.xxx, yyy.yyy, zzz.zzz ], ## Line[ 1 ][ 0 ] [ xxx.xxx, yyy.yyy, zzz.zzz ], [ xxx.xxx, yyy.yyy, zzz.zzz ], ... ], ... ); my( $x, $y, $z ) = $line[ $lineNo ][ $stationNo ];
My plan, if you can call it that, was to hold the line names (identifiers) in an array, since they may or may not start with a numeric. An annotated example of a portion of a SEG-P1 file is given below.

lineName stn. east...north...elev. 000301038 1260 52205121N109153806W 618485158009020 6626 000301038 1261 52205121N109153674W 618510158009027 6623 000301038 1262 52205120N109153542W 618535158009029 6621 000301016 400 52153542N109482654W 581401057903909 6738 000301016 401 52153542N109482522W 581426057903913 6738 000301016 402 52153542N109482390W 581451057903918 6738

The stn, east, north, and elev indicate the columns in which those values (station number, easting, northing, and elevation) are found throughout the file. (Note the change in line number/identifier part way through.) Station identifiers are always numeric, and, while they are arbitrarily assigned, I would like for any access to be according to these numbers. For example,

my( $x, $y, $z ) = $line[000301038][1261]; ... print "$x, $y, $z"; # Result: 6185101, 58009027, 6623
One reason I thought about using hashes here is because they are essentially associative arrays, so I can have a hash with the line name as the key, instead of some arbitrary number as the key. So instead of accessing according to $line[0][0] for the first station of the first line, I would prefer to say something like $line{32A-5}[101] for the first station of line 32A-5. This way there is no "first" or "last" line, only first and last stations (which makes sense, seeing as the survey is generally linear).