in reply to RE: (Ovid) Re: General quesion
in thread General quesion
Take a look at the scalar we're creating:
You'll notice that rand is being passed @myarray. Since rand is expecting a scalar, @myarray is interpreted in a scalar context. Therefore, it returns the length of the array (52 in this case), which will cause rand to generate a random number from 0 to 51, which fits the array index quite nicely. Perhaps this would have been more clear:$myarray[rand(@myarray)];
Cheers,$myarray[rand($#myarray)];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: RE: (Ovid) Re: General quesion
by merlyn (Sage) on Aug 08, 2000 at 06:36 UTC | |
|
RE: RE: RE: (Ovid) Re: General quesion
by johannz (Hermit) on Aug 08, 2000 at 22:35 UTC | |
by KM (Priest) on Aug 08, 2000 at 22:45 UTC | |
by tye (Sage) on Aug 08, 2000 at 23:27 UTC | |
by KM (Priest) on Aug 08, 2000 at 23:32 UTC | |
by tye (Sage) on Aug 08, 2000 at 23:58 UTC | |
|