Perl Brasil

Pesquisar

Documentação

Artigos

Planeta

Eventos

Comunidade

r1 - 06 Aug 2006 - JoenioCosta

Como ler um caractere

Problema

Você quer que o programa leia um caractere da entrada padrão, ou de outro filehandle.

Solução

use Term::ReadKey;

Discussão

Term::ReadKey is a compiled perl module dedicated to providing simple control over terminal driver modes (cbreak, raw, cooked, etc.,) support for non-blocking reads, if the architecture allows, and some generalized handy functions for working with terminals. One of the main goals is to have the functions as portable as possible, so you can just plug in "use Term::ReadKey" on any architecture and have a good likelyhood of it working.

ReadKey MODE [, Filehandle]

    Takes an integer argument, which can currently be one of the following values:

    0    Perform a normal read using getc
    -1   Perform a non-blocked read
    >0   Perform a timed read

Comentários