use v5.16; ... my @found= grep { my %r = reverse map fc, %$_; exists $r{cat} && exists $r{dog} } @pets;