Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_perl thread: Re: user input in loops


Message #1 by "George" <mouldy_goat@h...> on Thu, 5 Jul 2001 01:21:11
I'm not sure exactly what you're after, but the following code may help 
you:

#!/usr/bin/perl

while ($i ne "foo") { # infinite loop
print "A key was pressed!\n" if (<STDIN>);
}

Hope that helps you.

> Hi,
> 
> Does anyone know of a way to detect and collect user input without
> interrupting the operation of a loop?
> 
>  (Am on Win98 with activeperl)
> 
> (I want to terminate a loop gracefully; asking for <> just halts the 
loop,
> which is no good.)
> 
> Thanks,
> Peter
> 
> 

  Return to Index