ネストされたハッシュのキーのリストを取得したいのですが、その後のキーは
- 2 に等しくない、または
 - キーは事前定義されたキーに属していません。
 
以下の例では、目的の出力は " person_2"、" person_3"、および " person_4" です。これは、正確に 2 つのキーがないか、キーが定義済みのキーからのものではないためです。
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my @array = qw/place name/;
my %seen; 
$seen{$_}++ for @array;
my $hash = {
    person_1    => {
        name    => "name_1",
        place   => "place_1",
    },
    person_2    => {
        name    => "name_2",
        place   => "place_2",
        address => "address_2",
    },
    person_3    => {
        name    => "name_1",
    },
    person_4    => {
        who     => "name_1",
        where   => "place_1",
    },
};
foreach my $a (keys %$hash)
{
    print $a."\n" if (scalar(keys %{$hash->{$a}}) ne scalar(@array));
    foreach $b (keys %{$hash->{a}})
    {
        print $a."\n" unless $seen{$b};
    }
}
出力:
person_2
person_3
上記の出力は、正確な2つのキーがないためperson_2、適切ですperson_3
ただし、2 番目のforループ ロジックも同様に出力されているはずです。person_4正確に 2 つのキーがありますが、これらのキーは事前定義された@array.
ここで私が間違っていることを教えてください。
-ありがとう。