...

View Full Version : Just not reliable -- ideas?



dkenney1
01-27-2010, 03:30 AM
Wrote a little bit to give me 18 rands in a scratch.dat file and most of the time it does. It
does run into the hourglass from time to time and stop short at say 12 rands in scratch.dat.
Any ideas?


$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 =<SCR>;
close (SCR);
foreach $mine (@scra)
{
chomp($mine);
($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\n";
close(SCR);
$seen = 0;
$reps++;
}
}# End of lets do 18 reps...
#unlink ("scratch.dat");
&printout;
}
else
{
&signin;
}[/EMAIL]

dkenney1
01-27-2010, 05:07 AM
It struck me, would I have overlooked seen was set to zero before while and once it was
set to 1, it was not reset?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum