in reply to easy way to extract a hash from an array?
Your first snippet may contain a bug. You're pushing the same %person into @PEOPLE every time through the loop, unless %person is declared lexically on each iteration of the loop (ie, there has to be a my %person in the loop).
There isn't a way to avoid looping when you're looking for something inside of an array. You can grep, but that's still a loop:
my( @matches ) = grep { $_->{'fname'} eq 'John' } @PEOPLE;
Dave
|
|---|