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
fnord wrote:
>
> 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";
> ®_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?
|