Hyperiris has asked for the wisdom of the Perl Monks concerning the following question:
where $edtpost is a scalar containg multiple strings such as [roll=1], [roll=2], etc. The problem is, a) the function uses only the first $seed returned - that is, it always uses the same seed, even though $1 SHOULD be replaced. Also, b) the number returned is the same for EVERY iteration of the loop. Suggestions? Thanks in advancewhile ($edtpost =~ /\[roll=(\S+?)\]/i) { $seed = $1; if(!$seed || $seed > 12 || $seed < 1) { $seed=6; } srand(); $rndrslt = 0; $rndrslt = int(rand($seed)) + 1; print "$rndrslt\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: rand() problems
by danger (Priest) on Feb 27, 2001 at 10:26 UTC | |
|
Re: rand() problems
by merlyn (Sage) on Feb 27, 2001 at 10:18 UTC | |
by Hyperiris (Initiate) on Feb 27, 2001 at 10:19 UTC | |
by dws (Chancellor) on Feb 27, 2001 at 10:21 UTC |