my %states_with_comments = # and finnaly we will take keys from hash map { ((split /=/, $$_[0], 2)[1], 'hurray!') } # split first element on satename= and name, take name, make %key => 'hurray!" grep { $$_[2] } # test if array has 3-rd element that is comment map { values %$_ } # take arrays that are below PR, AK, WA, WV values %$db; # make list of hashes below numbers 99155, 26134