Irregular performance

Code is stupid...but people get mad if you dont try before asking for help. I get 18 rands to scratch.dat most of the time. However, some of the time, the hourglass comes up and I get only 12 results. Your ideas?
I appreciate it.
$seen = 0;
$reps = 1;
while ($reps < 19)
$random_number = int(rand(336)) +1;
if (-e "scratch.dat")
open (SCR, "scratch.dat") || &CgiDie ("SCRATCH could not be opened while attempting read");
@scra =;
close (SCR);
foreach $mine (@scra)
($junk, $num_to_check) = split (/|/, $mine);
if ($num_to_check == $random_number)
$seen = 1;
}#end of foreach line
}#end of if scratch data exists
if ($seen == 0)
open (SCR, ">>scratch.dat") || &CgiDie ("SCRATCH could not be opened while attempting write");
seek(SCR, 0, SEEK_END);
print SCR "junk|$random_number
$seen = 0;
}# End of lets do 18 reps...
#unlink ("scratch.dat");


  • I got it. $seen = 0; belongs after while. Otherwise seen remains one after the first duplicate is encountered and it goes on and on....
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion