hi
if i have arry with lots of intergers , how to check if there is duplicate integers
in perl ?
say I ahve @intergers=( 1,2,3,3,4,5,4,99,99,100)
hi
if i have arry with lots of intergers , how to check if there is duplicate integers
in perl ?
say I ahve @intergers=( 1,2,3,3,4,5,4,99,99,100)
If you just want to check (and maybe list) multiple occurrences, then:
$
$ perl -le '@x = (1,2,3,3,4,5,4,99,99,4,4,3,3,100); foreach $i (@x){$y{$i}++};
print "Multiple occurrences are: "; foreach (keys %y){print if $y{$_}>1}'
Multiple occurrences are:
99
4
3
$
$
tyler_durden
my @intergers=( 1,2,3,3,4,5,4,99,99,100);
map {$hash{$_}++} @intergers;
print join " -- ", grep {$hash{$_} == 1} keys %hash;