getc
if ($BSD_STYLE) { system "stty cbreak </dev/tty >/dev/tty 2>&1"; } else { system "stty", '-icanon', 'eol', "\001"; }
$key = getc(STDIN);
if ($BSD_STYLE) { system "stty -cbreak </dev/tty >/dev/tty 2>&1"; } else { system "stty", 'icanon', 'eol', '^@'; # ASCII null } print "\n";
Determination of whether $BSD_STYLE
should be set is left as
an exercise to the reader.
The POSIX::getattr() function can do this more portably on systems alleging
POSIX compliance. See also the
Term::ReadKey
module from your nearest
CPAN site; details on
CPAN can be found on
CPAN.