$ perl -le'print grep { $seen{$_} == 1 } map { $seen{$_}++; $_ } qw( a b a c );' bc