in reply to How to generate a unique word or number?

I would approach the problem in a simple manner

sub generate_random_string { my $res = ''; $res.= chr int rand(26)+96 for 1..8; return $res; }
Use this to generate a random string(with 8 letters).
After this you can just use a hash/hashref to assure no new string generated
is a duplicate with a past one

You can do this like this
my $h={}; sub generate_new_unique_random_str{ my $result; while(exists $h->{$result=generate_random_string()}) {}; return $result; }

The code above will store in $result each time the value returned by our
random string generator,and if it is not beeing found in the hash then
the loop terminates and the new generated value is returned

Originally posted as a Categorized Answer.