我想得到一系列独特的哈希,但我没有任何想法,并尝试了很多方法。请帮我解决这个问题:
注意:我不想使用任何Perl模块。
我尝试了什么:
%seen=();
@unique = grep { ! $seen{$_} ++ } @AoH;
@unique仍然没有独特的哈希值?
例如:
发件人:
@AoH = (
{
name => "susheel",
college => "MRITS",
},
{
name => "sunil",
college => "MRITS",
},
{
name => "susheel",
college => "MRITS",
},
);
以
@AoH = (
{
name => "susheel",
college => "MRITS",
},
{
name => "sunil",
college => "MRITS",
}
);
答案 0 :(得分:7)
按name
键
my %seen;
my @unique = grep { ! $seen{$_->{name}}++ } @AoH;