use strict; use warnings; my @cn1_new; my @cn1_newnnn = qw(apple orange grape apple lemon banana apple grape); my %ss; push(@cn1_new,grep {!$ss{$_}++} @cn1_newnnn); print "$_: $ss{$_}\n" for sort keys %ss; print "@cn1_new\n"; #### apple: 3 banana: 1 grape: 2 lemon: 1 orange: 1 apple orange grape lemon banana