in reply to Random Text: There's got to be an easier way

I've done something similar for ID numbers. It is indeed a little shorter:

my $length= 6; #how many digits to generate my @letters= split (//, '0123456789abcdefghijkmnopqrstuvwxyz'); sub create_new_ID { my $result; foreach my $iteration (1..$length) { $result .= $letters[int(rand(scalar @letters))]; } return $result; }
I didn't use the dotdot in the list constructor, as you see. I think you could have written 'a'..'z' (that is, use the quotes) and not get the bareword warning. However, note that I leave out 'l' because it looks too much like a '1', and it should be somewhat human readable/reproducable, right?

—John

Replies are listed 'Best First'.
(boo)Re: Random Text: There's got to be an easier way
by boo_radley (Parson) on Jun 04, 2001 at 00:25 UTC
    I didn't use the dotdot in the list constructor, as you see. I think you could have written 'a'..'z' (that is, use the quotes) and not get the bareword warning. However, note that I leave out 'l' because it looks too much like a '1', and it should be somewhat human readable/reproducable, right?
    human readable code is good too : my @letters= ("a".."k","m".."z","2".."9");