element has asked for the wisdom of the Perl Monks concerning the following question:
I have a complex data structure and I'm getting lost in the syntax. The top level of the structure is an array, let's call it "objarray" (about 90 elements). Each element of "objarray" is a hash. One of the hash's keys is called "apts". The value of that key is a 2D array (let's call it "aptarray"), consisting of 2 columns and several rows. How do I access the [3][1] element of "aptarray" in the 72nd element of the top-level "objarray"? The syntax I tried produces an error: "syntax error at test.pl line 292, near "][" "
292: my $value = @{$objarray[72]{'apts'}}[3][1];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Syntax for an array of hashes, with 2D array in hash value
by GrandFather (Saint) on Mar 08, 2011 at 04:23 UTC | |
|
Re: Syntax for an array of hashes, with 2D array in hash value
by wind (Priest) on Mar 08, 2011 at 04:36 UTC | |
by element (Novice) on Mar 08, 2011 at 07:38 UTC | |
by AnomalousMonk (Archbishop) on Mar 09, 2011 at 01:50 UTC | |
|
Re: Syntax for an array of hashes, with 2D array in hash value
by planetscape (Chancellor) on Mar 09, 2011 at 00:57 UTC |