[comp.lang.perl] time-limit on a <STDIN> ?

weisberg@hpccc.HP.COM (Len Weisberg) (08/02/90)

Any ideas on how to set a time-limit on a <STDIN> ?
If no input is received after a second or so, the program should 
continue to a graceful exit.

Thanks,

- Len Weisberg - HP Corp Computing & Services - weisberg@corp.HP.COM

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (08/04/90)

In article <12170009@hpccc.HP.COM> weisberg@hpccc.HP.COM (Len Weisberg) writes:
: Any ideas on how to set a time-limit on a <STDIN> ?
: If no input is received after a second or so, the program should 
: continue to a graceful exit.

If you have select:

	vec($rin,0,1) = 1;
	if (select($rout = $rin, undef, undef, 1.0)) {
	    $answer = <STDIN>;
	}

Other solutions with syscall come to mind.

If you're desperate, fork, sleep and kill.

Larry