in reply to Re: Dotted hash access
in thread Dotted hash access
$cost = $h->{$location}{$building} wouldn't work for me. The structure contains many more things than just Locations, and a location has much more data associated with it than a set of Buildings. So I don't want to accidentally get the wrong value back if I have a location name that happens to coincide with some other field name. (Perhaps I should give a more detailed dump of a data set?)
My approach differs from Perl4's because mine can be used hierarchically, unlike $;. So I am free to do
or whatever.$locinfo = $h->{"Locations.$location"}; count_totals($locinfo->{"Resources"}); compute_upkeep($locinfo->{"Buildings"});
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Dotted hash access
by brian_d_foy (Abbot) on Nov 25, 2004 at 19:24 UTC |