# perldoc > Term::ReadLine

---
type: CommandReference
command: Term::ReadLine
mode: perldoc
section: 3pm
source: perldoc
---

## Quick Reference
- `Term::ReadLine->new('appname')` — create a new ReadLine interface
- `$term->readline($prompt)` — read a line with readline support
- `$term->addhistory($line)` — add line to history
- `$term->IN` / `$term->OUT` — get input/output filehandles
- `$term->MinLine($size)` — set minimum line size for history
- `$term->Attribs` — get configuration hash reference
- `$term->Features` — get hash of supported features
- `$term->ornaments($ornament)` — set terminal standout

## Name
`Term::ReadLine` — Perl interface to various readline packages. If no real package is found, substitutes stubs instead of basic functions.

## Synopsis
perl
use Term::ReadLine;
my $term = Term::ReadLine->new('Simple Perl calc');
my $prompt = "Enter your arithmetic expression: ";
my $OUT = $term->OUT || \*STDOUT;
while ( defined ($_ = $term->readline($prompt)) ) {
    my $res = eval($_);
    warn $@ if $@;
    print $OUT $res, "\n" unless $@;
    $term->addhistory($_) if /\S/;
}
## Options / Methods
All methods are called on the object returned by `new()`.

### Core Methods
- `Term::ReadLine->new('appname', $IN, $OUT)` — Returns a handle. Argument is application name. Optionally followed by two filehandle globs for input and output.
- `ReadLine` — Returns the actual package (e.g., `Term::ReadLine::Gnu`, `Term::ReadLine::Perl`, `Term::ReadLine::Stub`).
- `$term->readline($prompt)` — Gets an input line, possibly with readline support. Trailing newline is removed. Returns `undef` on EOF.
- `$term->addhistory($line)` — Adds line to input history.
- `$term->IN` / `$term->OUT` — Returns filehandles for input/output, or `undef` if readline cannot be used for Perl.
- `$term->MinLine($size)` — Advice on minimum line size to include in history. `undef` means do not include anything. Returns old value.
- `$term->findConsole` — Returns array of two strings for input/output file names (e.g., `"<in"`, `">out"`). May not be useful for 3-argument open().
- `$term->Attribs` — Returns reference to hash of internal configuration, with leading `rl_` stripped.
- `$term->Features` — Returns reference to hash of features present in current implementation. Possible keys: `appname`, `minline`, `autohistory`, `addhistory`, `attribs`.

### Additional Methods (if supported by underlying package)
- `$term->tkRunning` — Makes Tk event loop run when waiting for user input.
- `$term->event_loop($wait_cb, $register_cb)` — Registers callbacks for waiting and registration. Deregister with `$term->event_loop(undef)`. Example with AnyEvent:
  ```perl
  $term->event_loop(sub {
      my $data = shift;
      $data->[1] = AE::cv();
      $data->[1]->recv();
  }, sub {
      my $fh = shift;
      my $data = [];
      $data->[0] = AE::io($fh, 0, sub { $data->[1]->send() });
      $data;
  });
  
- `$term->ornaments($ornament)` — Set terminal standout. Argument can be 0, 1, or a string "aa,bb,cc,dd" of terminal capacities.
- `$term->newTTY($in_fh, $out_fh)` — Switch to use different filehandles.

## Environment
- `PERL_RL` — Governs which ReadLine clone is loaded. If false, use dummy interface. If true, should be tail of package name (e.g., "Perl", "Gnu"). Can be space-separated with tail to disable ornaments (e.g., `"Perl o=0"`). If empty head, best available package is loaded.

## Examples
See Synopsis above.

## See Also
- [Term::ReadLine::Gnu](https://perldoc.perl.org/Term::ReadLine::Gnu)
- [Term::ReadLine::Perl](https://perldoc.perl.org/Term::ReadLine::Perl)
- [Term::ReadLine::Stub](https://perldoc.perl.org/Term::ReadLine::Stub)