Skip to content

Instantly share code, notes, and snippets.

@johnmccabe
Last active December 22, 2015 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnmccabe/6497518 to your computer and use it in GitHub Desktop.
Save johnmccabe/6497518 to your computer and use it in GitHub Desktop.
Breaking up hashes into lists based on values in the hash?
$hosts => {
'a.domain.com' => {
someparam => somevalue,
tags => [ 'red' ],
},
'b.domain.com' => {
someparam => someothervalue,
tags => [ 'red', 'green' ],
},
}
is there a way of getting lists out of the $hosts hash based on the tags array such that
redlist = ['a.domain.com', 'b.domain.com']
greenlist = ['b.domain.com']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment