my $uniq = 0; sub create_random { my @chars = ( "A" .. "Z", "a" .. "z", 0 .. 9, qw(! @ $ % ^ & *) ); my $user_name = join("", @chars[ map { rand @chars } ( 1 .. 10 ) ]); return $user_name . $uniq++; }