- Build a hash with each unique letter of the random input as a key and the number of times is appears asd a value (random hash). Do the same with the letters of the word suggested by the user (word hash) and check that the values in the word hash are always smaller than or equal to the values in the random hash.

- Sort all the random letters in alphabetical order, sort the letters of the word similarly, and compare the sorted arrays, one letter at a time.

You may also split the letters in arrays and use some Perl modules to compare lists, such as List::Utils, etc.

To verify, that a string contains only unique letters, you can use an arcane feature found in the tr operator in Perl. Assume that the string to check is stored in variable $x and that $x doesn't contain a forward slash (how to deal with this special case, is left as an exercise for you ;-). Now calculate the following:

The basic idea is to make a copy of the string and delete duplicate characters in the copy. If the new string is shorter than the old one, at least one character must have been duplicated.

Deleting duplicates is a side effect of the tr/// operator. tr is mainly used for translating one character set into another one, and the 'd' modifier causes duplicates to be removed. In our case, we are not interested in the translation proper, but only in the side effect done by 'd'.

Assume you are selecting 8 letters randomly (such as in the Scrabble game) and try to make up an existing word from some of the letters. The OP wants to check that all the letters in the word are in the random set of letters and that the word thus constructed is not using twice one of the ramdom letters. But if you have twice the same letter in the random set of letters, then that letter may be used twice (because you are using one copy of each existing letters), but not a third time.

For example, if the random letters contain "d e e g i n n v", you are entitled to compose the word EVENING, even though E and N both come twice in that word, because those two letters also come twice in the random set of letters. But you could not use the word EVENED, because you are entitled to 2 E's, not 3.