my $defined_x_no_y = grep { defined $_->{x} && !defined $_->{y} } values %hash; my $defined_z = grep { defined $_->{z} } values %hash;