I tried two of these methods and they both worked for me...
The method from zby was short and elegant looking, however the one from the cookbook gave me a result that more closely matched the input for some reason. Spotted a minor typo in that code though. Change line:
unless ($seen{$item})to
unless ($seen{$item}){
Good answers to the question though,
Martymart