in reply to How to group identical words?

Use a hash. Go read about them in perldata. Ask again if you get stuck.