perl - How to dereference entries in a hash of arrays of hashes -
i have data structure built so:-
$icvdwkey = "($llx $lly) ($urx $ury)"; ... push @{$icvdwstats{$icvdwkey}}, { icvdensity=>$density, icvlayerarea=>$layerarea, icvwindowarea=>$windowarea }; i can dereference contents so...
foreach $icvdwkey (@allicvdwcoords) { foreach (@{$icvdwstats{$icvdwkey}}) { $icvdensity = $_->{icvdensity}; $icvlayerarea = $_->{icvlayerarea}; $icvwindowarea = $_->{icvwindowarea}; ... } } ...and good. however, running problems when data structure built same way , need check contents when looping through original data structure, above. here example...
foreach $icvdwkey (@allicvdwcoords) { foreach (@{$icvdwstats{$icvdwkey}}) { $icvdensity = $_->{icvdensity}; $icvlayerarea = $_->{icvlayerarea}; $icvwindowarea = $_->{icvwindowarea}; ... if (exists ($icc2dwstats{$icvdwkey})) { $icc2density = $_->{icc2density}; $icc2layerarea = $_->{icc2layerarea}; $icc2windowarea = $_->{icc2windowarea}; ... } } } i know if exists $icvdwkey matching working properly, cannot cleanly dereference contents of icc2dwstats hash data. proper retrieve icc2* data when $icvdwkey keys match between 2 data structures? sure $_ in icc2* references, not know should used instead.
thanks!
instead of using $_ represents structure other $icc2dwstats hashref want, need explicitly specify hash , key of actual hasn want extract from:
for $icvdwkey (@allicvdwcoords) { (@{$icvdwstats{$icvdwkey}}) { $icvdensity = $_->{icvdensity}; $icvlayerarea = $_->{icvlayerarea}; $icvwindowarea = $_->{icvwindowarea}; ... if (exists ($icc2dwstats{$icvdwkey})) { $icc2density = $icc2dwstats->{$icvdwkey}{icc2density}; $icc2layerarea = $icc2dwstats->{$icvdwkey}{icc2layerarea}; $icc2windowarea = $icc2dwstats->{$icvdwkey}{icc2windowarea}; ... } } } note should using use strict; , use warnings;.
Comments
Post a Comment