in reply to removing duplicates from an array of hashes
Output:perl -MData::Dumper -E 'my $r=[map { id=>$_ }, ("a".."c","b")]; say Dumper $r; my %h; my @z= map {$h{$_->{id}}++ ?():$_ } @$r; say Dumper \@z'
$VAR1 = [ { 'id' => 'a' }, { 'id' => 'b' }, { 'id' => 'c' }, { 'id' => 'b' } ]; $VAR1 = [ { 'id' => 'a' }, { 'id' => 'b' }, { 'id' => 'c' } ];
What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
-Larry Wall, 1992
|
|---|