On Thursday, May 30, 2002, at 11:13 , Jeff 'japhy' Pinyan wrote:

> On May 30, drieux said:
>
>>> srand;
>>> $RandomScript = $Scripts[int(rand(@Scripts))];
>>>
>>      my $RandomScript = $Scripts[int(rand($#Scripts + 1))];
[..]
> Don't worry.  rand() requires its argument to be a scalar, so rand(@x) is
> like rand(scalar @x) (which is for all intents and purposes rand($#x+1)).
>
> I'm more concerned about the use of srand(), which is superfluous in
> recent Perls.  The int() is also superfluous.

good to hear that we do not have to go back quite to the perl4 tricks.

>
>   $element = @things[rand @things];

that works - but it makes me nervous...

http://www.wetware.com/drieux/pbl/perlTrick/randPick.txt



ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to