my %states_with_comments = map { ((split /=/, $$_[0], 2)[1], 'hurray!') } grep { $$_[2] } map { values %$_ } values %$db; print "states are: ", (join "; ", sort, keys %states_with_comments), "\n";