in reply to RE: Random number
in thread Random number

Regarding:

my $RandString = join("", @Chars[ map { rand @Chars } ( 1 .. 30 ) ]);

I'm wondering if I may inflict a question upon you--details about
that statement. I understand the purposes of "components" within it,
and I can certainly see the results when I run the script. But just
how it's generating those results is not clear to me. Could I talk you
into explaining a bit about how it works?

Thanks.

Replies are listed 'Best First'.
Random Array Slice
by chromatic (Archbishop) on Jul 10, 2000 at 21:45 UTC
    It's not too tricky. The rand statement imposes a scalar context on @Chars, so it gets a random number bounded by the number of elements in the array.

    The map statement creates a 30 element list of those random numbers.

    That list is used as indexes into an array slice. (That means that the second argument to the join statement is a random set of 30 characters from the @Chars array.) They're joined into a string.