in reply to creating all possible random 'words' from 4 letters

You could have a look at module Algorithm::Permute on CPAN.

Umm, how wonderful, it even has a sample code to do what you have asked!

The following code was pulled from CPAN
use Algorithm::Permute; my $p = new Algorithm::Permute(['a'..'d']); while (@res = $p->next) { print join(", ", @res), "\n"; }