What have you tried?
You should start by breaking up the problem into smaller steps, for example
- Compare just two hashes
- When you're satisfied with the code for it, and it does what you want, turn it into a subroutine
- Then it's just a matter of calling this sub three times, once with hashes 1 and 2, once with 1 and 3, and once with 2 and 3
- profit!
perlintro should get you started, perlfaq4 could be valuable too.