in reply to permutations?
You say that order is unimportant, but do you mean that the sentences can be in any order at all? You're using a hash reference to store the keys 'lng', 'sentance', and 'thxs', but hashes don't preserve any order whatsoever, so you're likely not going to get the keys in the same order you entered them into $words. If you want to keep the sentence parts in the same order, you might want to instead make it an array reference
my $words = [ ['lang', 'long', 'leng', 'loo'], ['sentence'], ['this', 'thus'] ];