in reply to How do I loop until keyboard input?

Using select will make your example work the way you seem to expect (type Q [Return] to quit).

As the other replies note, if you want it to take unbuffered input (i.e., you don't have to press [Return]), you should use Term::ReadKey.

my $done = 0; my $choice; my $rin = ''; vec($rin, fileno(STDIN), 1) = 1; my $timeout = 0; while (! $done) { print "Test\n"; if (select(my $rout=$rin, '', '', $timeout)) { chomp ( $choice = uc (<>)); $done = 1 if ( $choice eq "Q" ); } }

Caution: Contents may have been coded under pressure.