my $h={}; sub generate_new_unique_random_str{ my $result; while(exists $h->{$result=generate_random_string()}) {}; return $result; }