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"; }
In reply to rand() problems by Hyperiris
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |