use strict; use warnings; use strict; my @inColors = ( ['blue', 'foo'], ['red', 'bar'], ['blue', 'baz'], ); my %colors; for my $inColor (@inColors) { if (exists $colors{$inColor->[0]}) { print "Replacing $inColor->[0], $colors{$inColor->[0]} with $inColor->[1]\n"; } else { print "Adding $inColor->[0], $inColor->[1]\n"; } $colors{$inColor->[0]} = $inColor->[1]; } #### Adding blue, foo Adding red, bar Replacing blue, foo with baz