#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11112221 use warnings; my $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' ] } }; my @states; my @commentedstates; for ( values %$VAR1 ) { for ( values %$_ ) { local $_ = join "\n", @$_; push @states, /\bstate_name=(.*)/; /\bcomments=/ and push @commentedstates, $states[-1]; } } print "states :\n@states\n\n"; print "states with comments :\n@commentedstates\n\n";
Outputs:
states : West Virginia Washington Puerto Rico Alaska states with comments : West Virginia Washington
In reply to Re: Get all hash value into array
by tybalt89
in thread Get all hash value into array
by Magnolia25
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |