MAN page from Old RedHat 5.X perl-5.004-4.i386.rpm
Term::ReadLine
Section: Perl Programmers Reference Guide (3)
Updated: perl 5.004, patch 04
Index NAME
Term::ReadLine - Perl interface to various
readline packages. Ifno real package is found, substitutes stubs instead of basic functions.
SYNOPSIS
use Term::ReadLine; $term = new Term::ReadLine 'Simple Perl calc'; $prompt = "Enter your arithmetic expression: "; $OUT = $term->OUT || STDOUT; while ( defined ($_ = $term->readline($prompt)) ) { $res = eval($_), "\n"; warn $@ if $@; print $OUT $res, "\n" unless $@; $term->addhistory($_) if /\S/; } DESCRIPTION
This package is just a front end to some other packages. At the momentthis description is written, the only such package is Term-ReadLine,available on CPAN near you. The real target of this stub package is toset up a common interface to whatever Readline emerges with time.
Minimal set of supported functions
All the supported functions should be called as methods, i.e., either as
$term = new Term::ReadLine 'name';
or as
$term->addhistory('row');where
$term is a return value of Term::ReadLine->Init.
- ReadLine
- returns the actual package that executes the commands. Among possiblevalues are Term::ReadLine::Gnu, Term::ReadLine::Perl,Term::ReadLine::Stub Exporter.
- new
- returns the handle for subsequent calls to followingfunctions. Argument is the name of the application. Optionally can befollowed by two arguments for IN and OUT filehandles. Thesearguments should be globs.
- readline
- gets an input line, possibly with actual readlinesupport. Trailing newline is removed. Returns undef on EOF.
- addhistory
- adds the line to the history of input, from where it can be used ifthe actual readline is present.
- IN, $OUT
- return the filehandles for input and output or undef if readlineinput and output cannot be used for Perl.
- MinLine
- If argument is specified, it is an advice on minimal size of line tobe included into history. undef means do not include anything intohistory. Returns the old value.
- findConsole
- returns an array with two strings that give most appropriate names forfiles for input and output using conventions "<$in", ">out".
- Attribs
- returns a reference to a hash which describes internal configurationof the package. Names of keys in this hash conform to standardconventions with the leading rl_ stripped.
- Features
- Returns a reference to a hash with keys being features present incurrent implementation. Several optional features are used in theminimal interface: appname should be present if the first argumentto new is recognized, and minline should be present ifMinLine method is not dummy. autohistory should be present iflines are put into history automatically (maybe subject toMinLine), and addhistory if addhistory method is not dummy.
If Features method reports a feature attribs as present, themethod Attribs is not dummy.
Additional supported functions
Actually
Term::ReadLine can use some other package, that willsupport reacher set of commands.
All these commands are callable via method interface and have nameswhich conform to standard conventions with the leading rl_ stripped.
The stub package included with the perl distribution allows someadditional methods:
- tkRunning
- makes Tk event loop run when waiting for user input (i.e., duringreadline method).
- ornaments
- makes the command line stand out by using termcap data. The argumentto ornaments should be 0, 1, or a string of a form"aa,bb,cc,dd". Four components of this string should be names ofterminal capacities, first two will be issued to make the promptstandout, last two to make the input line standout.
- newTTY
- takes two arguments which are input filehandle and output filehandle.Switches to use these filehandles.
One can check whether the currently loaded ReadLine package supportsthese methods by checking for corresponding Features.
EXPORTS
None
ENVIRONMENT
The variable
PERL_RL governs which ReadLine clone is loaded. If thevalue is false, a dummy interface is used. If the value is true, itshould be tail of the name of the package to use, such as
Perl or
Gnu.
If the variable is not set, the best available package is loaded.
no real package is found, substitutes stubs instead of basic functions."
Index
- NAME
- SYNOPSIS
- DESCRIPTION
- Minimal set of supported functions
- Additional supported functions
- EXPORTS
- ENVIRONMENT
This document was created byman2html,using the manual pages.