|
Posted by Ignoramus31975 on March 30, 2007, 11:29 am
Please log in for more thread options
On 30 Mar 2007 15:06:06 GMT, anno4000@radom.zrz.tu-berlin.de
comp.lang.perl.misc:
>> On 30 Mar 2007 12:21:17 GMT, anno4000@radom.zrz.tu-berlin.de
>> comp.lang.perl.misc:
>> >> I have a script that runs in a loop and I would like it to accept
>> >> OPTIONAL keypresses.
>> >
>> > See "perldoc -q 'just one key'".
>> >
>> > Anno
>> Thanks, I just read this page
>>
>> LANG="" man Term::ReadKey
>>
>> and it looks like it will do just what I want.
>
> Right. That's what the FAQ answer also points to.
>
Yes, I got this idea from the FAQ answer. That's why I thanked you --
your suggestion was great.
I wrote this script to test stuff.
#!/usr/bin/perl
use Term::ReadKey;
sub CleanUp { ReadMode 0; }
$SIG = sub { CleanUp; die 'SIGINT CALLED'; };
$| = 1;
ReadMode 3;
while( 1 ) {
#print "Type key: ";
#usleep 10;
my $c = ReadKey(-1);
if( $c ) {
print "C='$c'. ";
if( $c eq 'q' || $c eq 'Q' ) {
print "\n'q' pressed. Exiting.\n";
last;
} else {
print "Press 'q' to exit.\n";
}
} else {
#print "\n";
}
}
CleanUp;
|