in reply to creating all possible random 'words' from 4 letters
You may want to check out the O'Reilly book Mastering Algorithms in Perl if you can.
It has a permutation sample and heap of other algorithms that are explained pretty well.