I have an array like this:
my @arr = (5, 76, 1000, 21, 47);
And this hash:
my %hash = (
Meta => [1000],
);
If any of the hash values matches any of the elements in the array, I want to print the key value of this match. For this, I use the following function, and it works:
my ($match) = grep { "@{$hash{$_}}" ~~ @arr } keys %hash;
The problem arises when there is more than one element in the hash of arrays, for example:
my %hash = (
Meta => [1000, 2],
);
In this case, I also want to return the key ("Meta"), since the value 1000 is in the array, but I do not understand it.
source
share