J
Jack
Hello,
The following removes duplicates from my array, however I cannot figure
out how to get Perl to also output the duplicate offender itself, since
I want to know "which" was the actual duplicate it removed on the
output... knowing what below is the duplicate is simple by looking at
the array (t1), but imagine a huge array, and you want to know "which"
were the dups after processing, what would I need to add to the code
below to output the actual duplicate being t1 ? Any tips are
appreciated :
@in = ("t1", "t2", "t1", "t3");
# Sort First, then Dedup
@in = sort @in;
# Start Dedup routine into @out array
print " IN ", $#in;
$prev = "not equal to $in[0]";
@out = grep($_ ne $prev && ($prev = $_, 1), @in);
print " OUT ", $#out;
Thank you !
Jack
The following removes duplicates from my array, however I cannot figure
out how to get Perl to also output the duplicate offender itself, since
I want to know "which" was the actual duplicate it removed on the
output... knowing what below is the duplicate is simple by looking at
the array (t1), but imagine a huge array, and you want to know "which"
were the dups after processing, what would I need to add to the code
below to output the actual duplicate being t1 ? Any tips are
appreciated :
@in = ("t1", "t2", "t1", "t3");
# Sort First, then Dedup
@in = sort @in;
# Start Dedup routine into @out array
print " IN ", $#in;
$prev = "not equal to $in[0]";
@out = grep($_ ne $prev && ($prev = $_, 1), @in);
print " OUT ", $#out;
Thank you !
Jack