time limited STDIN
Hi all, I wanted to know a way of taking a time limited STDIN. Say for eg after 3 seconds, the STDIN should stop waiting and move forward. How do I do this?? I was trying with unless ($child) { sleep($waittime); `echo "\n"`; exit 0; } $ans = ; but this didn't work out. So please help me thanks Saurabh
Re: time limited STDIN
On 1/4/07, Saurabh Singhvi <[EMAIL PROTECTED]> wrote: Hi all, I wanted to know a way of taking a time limited STDIN. Say for eg after 3 seconds, the STDIN should stop waiting and move forward. How do I do this?? I was trying with unless ($child) { sleep($waittime); `echo "\n"`; exit 0; } $ans = ; You can do this using the alarm function and an eval block as described here: <http://perldoc.perl.org/functions/alarm.html> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: time limited STDIN
Thanks a lot ! That does it :) On 1/4/07, Dave Gray <[EMAIL PROTECTED]> wrote: On 1/4/07, Saurabh Singhvi <[EMAIL PROTECTED]> wrote: > Hi all, > > I wanted to know a way of taking a time limited STDIN. Say for eg > after 3 seconds, the STDIN should stop waiting and move forward. > > How do I do this?? > > I was trying with > > unless ($child) { > sleep($waittime); > `echo "\n"`; > exit 0; > } > $ans = ; You can do this using the alarm function and an eval block as described here: <http://perldoc.perl.org/functions/alarm.html>