getc

NAME

getc - get the next character from the filehandle


SYNOPSIS

getc FILEHANDLE

getc


DESCRIPTION

Returns the next character from the input file attached to FILEHANDLE, or a null string at end of file. If FILEHANDLE is omitted, reads from STDIN. This is not particularly efficient. It cannot be used to get unbuffered single-characters, however. For that, try something more like:

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 to whether $BSD_STYLE should be set is left as an exercise to the reader.

See also the Term::ReadKey module from your nearest CPAN site; details on CPAN can be found on CPAN