in reply to what does rand[] return?

rand takes an optional argument. The argument you give it is [10], which is a reference to an (anonymous) array. Now, rand uses its argument as if it were a number. Perl happily casts types for you, and if use a reference (in this case [10]) as a number, you get its memory address. Which is a pretty big number. If you give rand a big number as argument, you get back a random number from 0 up till that big number.

And that's exactly what you are seeing.

Perl --((8:>*

Replies are listed 'Best First'.
Re^2: what does rand[] return?
by friedo (Prior) on Nov 30, 2005 at 14:06 UTC
Re^2: what does rand[] return?
by si_lence (Deacon) on Nov 30, 2005 at 11:34 UTC
    Thanks for the quick answer
    Makes perfect sense (now)
    si_lence