time limited STDIN

2007-01-04 Thread Saurabh Singhvi

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

2007-01-04 Thread Dave Gray

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

2007-01-04 Thread Saurabh Singhvi

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>