in reply to Re: Re: Generating Random Integers
in thread Generating Random Integers

the rand @array is taking @array in a scalar context. An array in scalar context returns the number of elements

Doesn't an array in scalar context return the index of the last element? i.e. if @array is a list of 10 values, I0's examples will be the equivalent of $array[rand 9]. rand 9 will effectively produce a random number between 0 and 8. This would mean that the last element in the array would never appear.

Update: I'm wrong as per tilly's comment below. See my humble-pie-eating act below that one. <half-grin>

Replies are listed 'Best First'.
Re (tilly) 4: Generating Random Integers
by tilly (Archbishop) on Jan 03, 2001 at 07:28 UTC
    An array in scalar context returns the number of elements in the array.

    As usual, I0 was both concise and correct.

      Drat! I'm tired. confused with $#array. Good night.