It helps us help you better if you are more explicit about where exactly you encounter problems.
What part of perlfaq4 is problematic for you? I think especially the section on How can I remove duplicate elements from a list or array applies to your problem.
Maybe you can adapt the code and approach presented there and get back to us when you encounter concrete problems. Please take the time to describe the problem you encounter, together with the input you give, the output you get and the output you expect.