in reply to Unique list of hashes

Like this?

use strict; use warnings; use Data::Dumper; my @students = ( { name => "Gil", college => "Yale", }, { name => "Gil", college => "Harvard", }, { name => "Gil", college => "Harvard", }, ); my @unique = do { my( %seenName, %seenCollege ); grep { !$seenName{$_->{name}}++ or !$seenCollege{$_->{college}}++ +} @students}; print Dumper \@unique;

UPDATE: Sorry, got that wrong. It should be:

my @unique = do { my %seen; grep { !$seen{$_->{name}}{$_->{college}}++ } @students};

Replies are listed 'Best First'.
Re^2: Unique list of hashes
by mrguy123 (Hermit) on Mar 02, 2015 at 11:36 UTC
    Nice!!
    I was actually thinking along the line of your first solution, but couldn't get figure out how to take care of the "or". I think this is just what I need.
    Thanks!