Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Get all hash value into array

by tybalt89 (Monsignor)
on Feb 01, 2020 at 18:40 UTC ( [id://11112235]=note: print w/replies, xml ) Need Help??


in reply to Get all hash value into array

#!/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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11112235]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-25 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found