in reply to default value after timeout
alternatives are all welcomed
perldoc perlipc shows how to setup a timeout; you might try to modify it for your needs (untested).
sub getinput { my $default = shift; my $value; eval { local $SIG{ALRM} = sub { die "alarm clock restart" }; alarm 10; # your code here, read <STDIN> $value = ... alarm 0; }; if ($@ and $@ !~ /alarm clock restart/) { return $default } return $value; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: default value after timeout
by Limbic~Region (Chancellor) on Aug 29, 2002 at 22:41 UTC |