blazar,
If I am understanding the question correctly, this is not a FAQ and your solution has nothing to do with the question being asked.
The object isn't to remove duplicates but to find the first entry that doesn't have a duplicate and then print the corresponding element (via the index) in another array.
my (@name1, @name2, @percent); # initialized elsewhere
my %seen;
++$seen{$_} for @name1;
for ( 0 .. $#name1 ) {
next if $seen{ $name[$_] } > 1;
print $name2[$_];
last;
}
It is completely possible that I am the one who has interpreted the problem wrong though.
Update: Oversight corrected thanks to blazar below. That's what you get for not testing your code ;-)
|