getting closer on the timer

F

fnord

Here's what I've got for the timer:

#################################
# timer
#################################
sub timer
{
$timeout = 180;
$SIG{ALRM} = sub {die;};
eval
{
alarm($timeout);
$start = time();

print "Welcome to the game, here are your letters:\n";
&reg_roll();
print "\n";

$timeRemaining = $timeout - (time() - $start);
while ($timeRemaining > 0)
{
alarm($timeRemaining);
&input;
}
};
print "\nTime's up!\n";
}


For some reason it's not timing out after 180 seconds, it's running for anywhere from 6 to 9 minutes.

Any ideas as to why?
 
E

Eric Frazier

Hi,

What do time() and &input do/return? I don't see how you ever get to
&input if for some reason $timeremaining never gets to zero. Can't tell
much else withone knowing how the whole thing works though. First thing
I would do is print to a file the loop values, and make sure they are
incing like you expect them to. I also would wonder how alarm deals with
non integer numbers, maybe it just rounds to the int, but make it does
something weird.

Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top