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

Replies are listed 'Best First'.
Re: Answer: How to generate a unique word or number?
by Your Mother (Archbishop) on Mar 15, 2008 at 18:19 UTC

    The operative word is "unique" though not "random." So I think one of the UID generating modules, like Data::UUID (and there are two or three others IIRC), would be the right answer.