in reply to Duplicate lines with spaces, tabs...

I know it can be done with regex, but I'm a real beginner in perl and regex still looks very hard to me. Thx in advance

A regex isn't always the best way, what you have so far seems just fine for me, both in terms of correctness and in complexity. Sure, you can assemble all lines into a regex instead of a hash, but it will only bring you closer to insanity.

Update: Uhm, I think I mis-read the question. The concern seems to be the duplicate 5 in the output, which seems to be caused by trailing whitespaces. You can remove those with a second regex:

s/[\t ]+$//;

Second Update: Contrary to what others have written, s/\s+$// isn't enough, because it also strings the trailing newline, thus deletes all newline characters from your file (unless you add them to the print statement separately)