markseger has asked for the wisdom of the Perl Monks concerning the following question:
When there's input, I print ">>> GOT INPUT". Then I read it and print its value. If I type 8900098 the following is what I see:
root@poker collectl# ./sht.pl >>> GOT INPUT INPUT: 56 >>> GOT INPUT INPUT: 57 >>> GOT INPUT >>> GOT INPUT >>> GOT INPUT >>> GOT INPUT INPUT: 57 >>> GOT INPUT INPUT: 56
so what happened to the echos of the '0's? Here's the code that does it:
#!/usr/bin/perl -w use Term::ReadKey; use IO::Select; ReadMode 4; my $sel=new IO::Select(STDIN); my $ctrlCFlag=0; while (!$ctrlCFlag) { while(my @ready = $sel->can_read(1)) { foreach my $filehandle (@ready) { if ($filehandle eq 'STDIN') { print ">>> GOT INPUT\n"; while (my $char=ReadKey -1) { my $byte=unpack('C', $char); printf "INPUT: %d\n", $byte; if ($byte==3) { $ctrlCFlag=1; last; } } } } } } ReadMode 0;
can_read() says there's something to be read on STDIN but ReadKey isn't see anything. And what's so special about '0'? Isn't it just another key? Any and all help will be greatly appreciated. -mark
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ReadKey can't see 0 key...
by Tanktalus (Canon) on Nov 11, 2010 at 20:41 UTC | |
by markseger (Beadle) on Nov 11, 2010 at 21:17 UTC | |
|
Re: ReadKey can't see 0 key...
by SuicideJunkie (Vicar) on Nov 11, 2010 at 20:21 UTC |