I am able to manage to create the data structure as below.
$VAR1 = { '99155' => { 'PR' => [ 'state_name=Puerto Rico', 'county_names_all=Adjuntas|Utuado', ], 'AK' => [ 'state_name=Alaska', 'county_names_all=Ketchikan Gateway|Prince of + Wales-Hyder', ], 'WA' => [ 'state_name=Washington', 'county_names_all=Pend Oreille|Spokane|Lincol +n|Adams', 'comments=America/Los_Angeles' ] }, '26134' => { 'WV' => [ 'state_name=West Virginia', 'county_names_all=Wirt|Wood|Jackson|Ritchie| +Calhoun', 'comments=America/New_York' ] } };
But Now I Need to get all the "state_name" in above structure into an array.
@array = ('Puerto Rico', 'Alaska', 'Washington', 'West Virginia');and another array as (Filter "state_name" for which "comments" is present)
@array = ('Puerto Rico', 'Alaska');So far i tried
for my $outerkey (keys %hash) { for my $innerkey (keys $hash{$outerkey}) { print join(', ', @{ $hash{$outerkey}{$innerkey} } ); push( @{ $hash{$outerkey}{$innerkey} }, @array); } }
Please help.
In reply to Get all hash value into array by Magnolia25
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |