in reply to Get all hash value into array
Here's the most simple solution I found... The power of perl :) :)
#!/usr/bin/perl use utf8; use Modern::Perl; use Data::Dumper; my $db = { '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' ] } }; my %states = map { ((split /=/, $$_[0], 2)[1], 'hurray!') } map { values %$_ } values %$db; print "states are: ", (join "; ", sort, keys %states), "\n";
result is:
root@orion:/tmp# ./mytest.pl states are: West Virginia; Puerto Rico; Washington; Alaska
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Get all hash value into array
by LanX (Saint) on Feb 02, 2020 at 13:07 UTC | |
by leszekdubiel (Scribe) on Feb 02, 2020 at 13:30 UTC |