$Easting{$Line}{$Station}
That implies you intend to have 3 hashes, one for each of x, y & z. Parallel data structures are not (generally) a good idea as they can get out of sync and you're stuffed. Going by the line diagram, you'd be better off with something that allowed you to do:
my %line = (
lineNameA => {
StationA => [ xxx.xx, yyy.yy, zzz.zz ],
StationB => [ xxx.xx, yyy.yy, zzz.zz ],
...
},
lineNameB => {
...
);
my( $x, $y, $z ) = $line{ $lineName }{ $stationName };
# Or
use constant{ X => 0, Y => 1, Z => 2 };
my $y = $line[ $lineNo ][ $staionNo ][ Y ];
That's assuming the the identifiers are names not numbers.
If they are numbers, or names of the form "line_003" and "station_12", (low, mostly sequential number postfixes ),
then you'd save some memory and be a tad quicker to use arrays instead of hashes:
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 ];
# Or
use constant{ X => 0, Y => 1, Z => 2 };
my $y = $line[ $lineNo ][ $staionNo ][ Y ];
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
-
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.