#!/usr/bin/perl while (){ chomp; $h{$_}++; } for ( sort grep { $h{$_} != 1 } keys %h ) { print "$_\n"; } __DATA__ A(01) B(02) C(03) A(01) D(04) E(05)