I have a list of strings and I need to remove all items that are unique or has more than one duplicate. Other words, I need just those items, that are in the list exactly twice. How can I do it in Perl?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s a special case of the classic remove duplicates recipe. When your items are strings, this is really easy in Perl 5:
It’s O(N) on the size of the list, but I don’t think you can get away with doing this kind of thing without looking at every element at least once…