in reply to Re^2: Syntax for an array of hashes, with 2D array in hash value
in thread Syntax for an array of hashes, with 2D array in hash value
The top level of the structure is an array, let's call it "objarray" ...
my @objarray = ();
...(about 90 elements). Each element of "objarray" is a hash.
my @objarray = ( { }, { }, ({ }) x 87, # 87 more elements... { }, );
One of the hash's keys is called "apts".
my @objarray = ( { 'apts' => '???', }, { 'apts' => '???', }, ({ 'apts' => '???', }) x 87, { 'apts' => '???', }, );
The value of that key is a 2D array ... consisting of 2 columns and several rows.
my @objarray = ( { 'apts' => [ [11,12], [13,14], [15,16], ], }, { 'apts' => [ [21,22], [23,24], [25,26], ], }, ({ 'apts' => '???', }) x 87, { 'apts' => [ [91,92], [93,94], [95,96], ], }, );
>perl -wMstrict -le "my @objarray = ( { 'apts' => [ [11,12], [13,14], [15,16], ], }, { 'apts' => [ [21,22], [23,24], [25,26], ], }, ({ 'apts' => '???', }) x 87, { 'apts' => [ [91,92], [93,94], [95,96], ], }, ); ;; print 'elements in array: ', scalar @objarray; print $objarray[89]{'apts'}[2][1]; " elements in array: 90 96
(I cheated a bit on the construction of the array and so could not use the indices in the OP, but you get the idea.)
|
|---|