Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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).


In reply to Re^2: Data Structures by YYCseismic
in thread Data Structures by YYCseismic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-20 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found