Possible Duplicate:
What's the most efficient way to check for duplicates in an array of data using Perl?
How to find duplicate values in array?
This is my array:
@arr - ("one","two","one","three","two");
Output will be:
one
two
Code:
while (<RFH>) {
chomp;
@arr = split(/\|/,$_);
push(@arr1,$arr[4]."\n");
}
One pass solution:
my %seen = ();
@dup = map { 1==$seen{$_}++ ? $_ : () } @list;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With