Cheap web site hosting service by Active-Venture.com
  

 Back to Index

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. 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:

 
    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 purporting POSIX compliance. See also the Term::ReadKey module from your nearest CPAN site; details on CPAN can be found on perlmodlib/CPAN.

 

  

 

Domain registration - Domain registration service and cheap domain transfer
 

Cheap domain name: Register domain name -
Register domain name services from just
$8.95/year only
 

Register domain name search -
Register domain or buy domain name registration and cheap domain transfer at low, affordable price.

© 2002-2004 Active-Venture.com Web Site Hosting Service

 

[ There are two major products that come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.   ]

 

 
 
 

Disclaimer: This documentation is provided only for the benefits of our web hosting customers.
For authoritative source of the documentation, please refer to http://www.perldoc.com