Differences between version 2 and previous revision of perlfaq8(1).
Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 2 | Last edited on Tuesday, June 4, 2002 12:22:34 am | by perry | Revert |
Older page: | version 1 | Last edited on Tuesday, June 4, 2002 12:22:34 am | by perry | Revert |
@@ -57,11 +57,11 @@
Keyboard
Term::Cap Standard perl distribution
-Term::ReadKey CPAN
-Term::ReadLine::Gnu CPAN
-Term::ReadLine::Perl CPAN
+Term::!
ReadKey CPAN
+Term::!
ReadLine::Gnu CPAN
+Term::!
ReadLine::Perl CPAN
Term::Screen CPAN
Screen
@@ -111,25 +111,25 @@
snags.
open(TTY,
-The Term::ReadKey module from CPAN offers an easy-to-use interface that should be more efficient than shelling out to __stty__ for each key. It even includes limited support for Windows.
+The Term::!
ReadKey module from CPAN offers an easy-to-use interface that should be more efficient than shelling out to __stty__ for each key. It even includes limited support for Windows.
- use Term::ReadKey;
-ReadMode('cbreak');
-$key = ReadKey();
-ReadMode('normal');
+ use Term::!
ReadKey;
+!
ReadMode('cbreak');
+$key = !
ReadKey();
+!
ReadMode('normal');
However, using the code requires that you have a working C compiler and can use it to build and install a CPAN module. Here's a solution using the standard POSIX module, which is already on your systems (assuming your system supports POSIX ).
- use HotKey;
+ use !
HotKey;
$key = readkey();
-And here's the HotKey module, which hides the somewhat mystifying calls to manipulate the POSIX termios structures.
+And here's the !
HotKey module, which hides the somewhat mystifying calls to manipulate the POSIX termios structures.
- # HotKey.pm
-package HotKey;
+ # !
HotKey.pm
+package !
HotKey;
@ISA = qw(Exporter);
@EXPORT = qw(cbreak cooked readkey);
use strict;
use POSIX qw(:termios_h);
@@ -157,21 +157,21 @@
keyboard?__
The easiest way to do this is to read a key in nonblocking
-mode with the Term::ReadKey module from CPAN
+mode with the Term::!
ReadKey module from CPAN
, passing it an argument of -1 to indicate not to
block:
- use Term::ReadKey;
- ReadMode('cbreak');
- if (defined ($char = ReadKey(-1)) ) {
+ use Term::!
ReadKey;
+ !
ReadMode('cbreak');
+ if (defined ($char = !
ReadKey(-1)) ) {
# input was waiting and it was $char
} else {
# no input was waiting
}
- ReadMode('normal'); # restore normal tty settings
+ !
ReadMode('normal'); # restore normal tty settings
__How do I clear the screen?__
@@ -195,15 +195,15 @@
__How do I get the screen size?__
-If you have Term::ReadKey module installed from
+If you have Term::!
ReadKey module installed from
CPAN , you can use it to fetch the width and
height in characters and in pixels:
- use Term::ReadKey;
-($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize();
+ use Term::!
ReadKey;
+($wchar, $hchar, $wpixels, $hpixels) = !
GetTerminalSize();
This is more portable than the raw ioctl, but not as illustrative:
require 'sys/ioctl.ph';
@@ -226,15 +226,15 @@
varying degrees of portability.
You can also do this for most systems using the
-Term::ReadKey module from CPAN , which is
+Term::!
ReadKey module from CPAN , which is
easier to use and in theory more portable.
- use Term::ReadKey;
- ReadMode('noecho');
-$password = ReadLine();
+ use Term::!
ReadKey;
+ !
ReadMode('noecho');
+$password = !
ReadLine();
__How do I read and write the serial port?__
@@ -486,16 +486,16 @@
If you want finer granularity than the 1 second that the
''sleep()'' function provides, the easiest way is to use
the ''select()'' function as documented in ``select'' in
-perlfunc. Try the Time::HiRes and the BSD::Itimer modules
+perlfunc. Try the Time::!
HiRes and the BSD::Itimer modules
(available from CPAN ).
__How can I measure time under a second?__
-In general, you may not be able to. The Time::HiRes module
+In general, you may not be able to. The Time::!
HiRes module
(available from CPAN ) provides this
functionality for some systems.
@@ -551,9 +551,9 @@
distribution).
If you want the ''atexit()'' syntax (and an
-''rmexit()'' as well), try the AtExit module available
+''rmexit()'' as well), try the !
AtExit module available
from CPAN .
__Why doesn't my sockets program work under System V
@@ -610,9 +610,9 @@
If your system doesn't support dynamic loading, you still
probably ought to use h2xs. See perlxstut and
-ExtUtils::MakeMaker for more information (in brief, just use
+!
ExtUtils::!
MakeMaker for more information (in brief, just use
__make perl__ instead of a plain __make__ to rebuild
perl with a new static extension).
@@ -1019,9 +1019,9 @@
Use the ''alarm()'' function, probably in conjunction
with a signal handler, as documented in ``Signals'' in
perlipc and the section on ``Signals'' in the Camel. You may
-instead use the more flexible Sys::AlarmCall module
+instead use the more flexible Sys::!
AlarmCall module
available from CPAN .
__How do I set CPU limits?__
@@ -1125,9 +1125,9 @@
__make perl__ and you will get a new ''perl'' binary
with your extension linked in.
-See ExtUtils::MakeMaker for more details on building
+See !
ExtUtils::!
MakeMaker for more details on building
extensions. See also the next question, ``What's the
difference between require and use?''.
@@ -1178,9 +1178,9 @@
__How do I add the directory my program lives in to the
module/library search path?__
- use FindBin;
+ use !
FindBin;
use lib
__How do I add a directory to my include path at