This assumes that there is at least one:
my %hash = %{(grep {exists $_->{'foo'}} @hashes)[0]};
Your code is incorrect in both lines. In the first, $hashref will be set to the number of matches, and you need %hash=%$hashref in the second. Recommend tye's References quick reference to help with errors like that
Perl hashes don't really have 'primary' keys in the way that databases do.
After Compline,
Zaxo
In reply to Re: Dereference array-elements
by Zaxo
in thread Dereference array-elements
by very empty
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |