Perl Cd Bookshelf [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Perl Cd Bookshelf [Electronic resources] - نسخه متنی

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید



15.9. Checking for Waiting Input


15.9.1. Problem



You want to know whether
keyboard input is waiting without actually reading it.

15.9.2. Solution


Use the CPAN module Term::ReadKey, and try to read a key in
non-blocking mode by passing it an argument of
-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

15.9.3. Discussion


The -1 parameter to ReadKey
indicates a non-blocking read of a character. If no character is
available, ReadKey returns
undef.

15.9.4. See Also


The documentation for the Term::ReadKey module from CPAN; Recipe 15.6



15.8. Using POSIX termios15.10. Reading Passwords




Copyright © 2003 O'Reilly & Associates. All rights reserved.

/ 875