in reply to Nested Data Structures for Dummies?
Do you have a favorite "Accessing Data in Nested Structures for Complete Idiots" tutorial
Bad question. Don't access data in a nested structure. Access the data you have at hand.
One would access the countries in a list of counties as follows:
for my $country_name (keys(%$countries)) { my $country = $countries->{$country_name}; ... }
One would access the provinces in a list of provinces as follows:
for my $province_name (keys(%$provinces)) { my $province = $provinces->{$province_name}; ... }
Maybe $provinces is the same as $country or $country->{provinces} or $country->get_provinces(). Does it matter? No.
for my $country_name (keys(%$countries)) { my $country = $countries->{$country_name}; my $provinces = $country->{provinces}; for my $province_name (keys(%$provinces)) { my $province = $provinces->{$province_name}; ... } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Nested Data Structures for Dummies?
by jedikaiti (Hermit) on Apr 15, 2010 at 00:59 UTC | |
by ikegami (Patriarch) on Apr 15, 2010 at 01:03 UTC | |
by jedikaiti (Hermit) on Apr 15, 2010 at 17:38 UTC |