I don't get that error. Are you certain that what you have is an array of hashes? Here is a one-liner which shows that it works:
perl -Mstrict -Mwarnings -MData::Dumper -e
'my @array = ( { foo => 1 }, { }, { }, { foo => 2 } ); my
@elements = grep { exists $_->{foo} } @array; print Dumper
\@elements'
$VAR1 = [
{
'foo' => 1
},
{
'foo' => 2
}
];
|