Inspired by the answer to this other question: Slicing a nested hash in Perl, what is the syntax for slicing a hash using a list of keys held in another hash?
I thought the following would do it, but it doesn’t:
@slice_result = @{$hash1{@($hash_2{$bin})}};
I get an error that says "scalar found where operator expected". ?
Your ambiguous description of your data make me think you’re not even sure of what you have. You should spend some time absorbing the structure of your data until you can describe it clearly.
I think you are saying you have
You want to use the array referenced by one of the elements on %hash2 as the keys of a slice of %hash1. If you understand that, it’s just a question of doing it step by step.
will get us the reference to the desired array, and
will get us the array itself. We want to use that as the index expression of a hash slice
so we get: