The Wayback Machine - https://web.archive.org/web/20160117181600/http://perldoc.perl.org/functions/getc.html

Perl version

Modules

  • ABCDE
  • FGHIL
  • MNOPS
  • TUX

getc

Perl 5 version 22.0 documentation

Please note: Many features of this site require JavaScript. You appear to have JavaScript disabled, or are running a non-JavaScript capable web browser.

To get the best experience, please enable JavaScript or download a modern web browser such as Internet Explorer 8, Firefox, Safari, or Google Chrome.

Recently read

getc

  • getc FILEHANDLE

  • getc

    Returns the next character from the input file attached to FILEHANDLE, or the undefined value at end of file or if there was an error (in the latter case $! is set). If FILEHANDLE is omitted, reads from STDIN. This is not particularly efficient. However, it cannot be used by itself to fetch single characters without waiting for the user to hit enter. For that, try something more like:

    1. if ($BSD_STYLE) {
    2. system "stty cbreak </dev/tty >/dev/tty 2>&1";
    3. }
    4. else {
    5. system "stty", '-icanon', 'eol', "\001";
    6. }
    7. $key = getc(STDIN);
    8. if ($BSD_STYLE) {
    9. system "stty -cbreak </dev/tty >/dev/tty 2>&1";
    10. }
    11. else {
    12. system 'stty', 'icanon', 'eol', '^@'; # ASCII NUL
    13. }
    14. 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 purporting POSIX compliance. See also the Term::ReadKey module from your nearest CPAN site.

 
Morty Proxy This is a proxified and sanitized view of the page, visit original site.