# from script.pl %some_hash = ( 'NEW_YORK' => { 'capital' => 'Albany', 'colors' => 'black, green, blue', 'bird' => 'pigeon' }, 'MASSACHUSETTS' => { 'capital' => 'Springfield', 'color' => 'red, white, blue', 'bird' => 'turkey' } # etc )
What I'd like to do is grab this hash and then use the data contained within it to make my own hash. Specifically, since there can be multiple values associated with the 'color' key, I'd like to make a hash whose keys are individual colors, and whose values are the states that use those colors (a sort of 'reverse' of part of the first hash).
I know how to read a file in from a filehandle, and (theoretically) how to find the %some_hash variable. I need help with either:
1. Locating the %some_hash and reading all of it into my own hash.
OR
2. Is there some way to use this hash assignment in my own script--without executing the script.pl that %some_hash appears in?
Just pointing me in the right direction is enough... I think I basically know what to do but I'm getting bogged down in the scale of it.
Thanks,
AH
In reply to sorting a hash that's in another file by alienhuman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |