The
%seen hash is there to remove duplicate words from the input. If a word in $key has nos been seen, then
$seen{$key} will not exist and return a false value, so that we will continue the process; at the same time, the hash entry will be created for the key and the value will be 1. If the word has been seen, then
$seen{$key} will exist and return a true value (1, the first time you see a duplicate word, then 2, 3...), we will go back to the top of the loop starting with the next input word.
The %word hash will have normalized words (i.e. with letters put in alphabetic orders) or signatures as keys, and for each such key, will contain an anonymous array of the original words that were translated into this signature. In other words, if an array in the hash or arrays has more than one entry, then it means that two or more words matched the normalized signature and that we have an anagram.
I hope this makes it clearer.