in reply to Term::Readkey GetConsoleMode error

i wish there was a more obviouse way to do this. I want to mimic the getchar/getc function from C in perl. There is getc in perl but it doesnt doesnt stop reading after each char. Also it always echo's.

Even posix doesnt support this because of the perl getc function. *grumble grumble grumble*

Replies are listed 'Best First'.
Re^2: Term::Readkey GetConsoleMode error
by zer (Deacon) on Mar 22, 2006 at 06:16 UTC
    hrrmmm.... in O'Reilly's "Programing Perl" it says, "Avoid getc for anything but single-character terminal I/O. In fact, dont use it for that either. Use sysread."

    #!/usr/bin/perl use warnings; use strict; my $c; my $t = sysread STDIN,$c,1; print "You input $c with $t";

    This still doesnt work... It gets an infinite amount of input and never exits. Am i doing this right?