[johnsca@CORY tmp]$ cat tst.pl #!/usr/bin/perl my @Tapes = ( ['Label 1', 'p', 'l', 'P'], ['Label 1', 'p', 'l', 'P'], # Duplicate ['Label 2', 'p', 'l', 'P'], ['Label 3', 'p', 'l', 'P'], ); hash_tapes(@Tapes); sub hash_tapes (@) { my @tapes = @_; my %Tape_Cat =(); foreach my $tape (@tapes) { my ( $label, $protection, $location, $pool ) = @{$tape}; push @{ $Tape_Cat{$label} }, [ $protection, $location, $pool ]; } # Get rid of non-duplicates my $count = 0; foreach my $tape (@tapes) { my ($label,$protection,$location,$pool) = @{$tape}; if ( @{$Tape_Cat{ $label}} < 2 ) { print "Deleting ". $label. "Because it has ".@{$Tape_Cat{ $label }}. " record(s)\n"; $count++; delete $Tape_Cat{$label} } } my @keys = keys %Tape_Cat; print "Deleted $count keys, keys: @keys\n"; return \%Tape_Cat; } [johnsca@CORY tmp]$ ./tst.pl Deleting Label 2Because it has 1 record(s) Deleting Label 3Because it has 1 record(s) Deleted 2 keys, keys: Label 1