# perldoc > Term::Cap

---
type: CommandReference
command: Term::Cap
mode: perldoc
section: 3
source: perldoc
---

## Quick Reference
- `Tgetent { TERM => undef, OSPEED => $ospeed }` — get terminal capability object
- `$terminal->Tgoto('cm', $col, $row, $FH)` — decode cursor addressing string
- `$terminal->Tputs('cap', $count, $FH)` — output padded string without parameter substitution
- `$terminal->Tpad($string, $count, $FH)` — output literal string with padding
- `$terminal->Trequire(qw/ce ku kd/)` — require capabilities, croak if missing

## Name
Term::Cap — Perl termcap interface

## Synopsis
perl
require Term::Cap;
$terminal = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed };
$terminal->Trequire(qw/ce ku kd/);
$terminal->Tgoto('cm', $col, $row, $FH);
$terminal->Tputs('dl', $count, $FH);
$terminal->Tpad($string, $count, $FH);
## Options (Methods)
- **`Tgetent`** — Returns blessed object. Extracts terminal entry from termcap database. Arguments: hash ref with optional keys `OSPEED` (terminal output bit rate, default 9600) and `TERM` (defaults to `$ENV{TERM}`). Croaks on failure. Searches `$HOME/.termcap`, `/etc/termcap`, `/usr/share/misc/termcap` unless `TERMPATH` or `TERMCAP` environment variables are set. If `TERMCAP` is set and does not start with `/`, and terminal type name matches `$ENV{TERM}`, uses `TERMCAP` string directly. If `TERMCAP` starts with `/`, uses as path to termcap file. If `TERMCAP` does not start with `/` and name differs, searches files in order. Whenever multiple files are searched, a `tc` field must be found in same or succeeding file. The extracted entry is available as `$self->{TERMCAP}`.
- **`Tpad($string, $cnt, $FH)`** — Outputs literal string with padding. If `$string` starts with a number and optional `*`, padding increased by that amount (multiplied by `$cnt` if `*` present). The numeric prefix is removed before output. `$FH` is optional filehandle. Returns padded string.
- **`Tputs($cap, $cnt, $FH)`** — Outputs string for given capability padded without parameter substitution. If `$cnt` is 0 or 1, result cached. Returns appropriate string.
- **`Tgoto($cap, $col, $row, $FH)`** — Decodes cursor addressing string with substitutions. Substitutions: `%%` (output `%`), `%d` (printf %d), `%2` (printf %2d), `%3` (printf %3d), `%.` (printf %c), `%+x` (add x then `%.`), `%>xy` (if value > x then add y, no output), `%r` (reverse order of two parameters), `%i` (increment by one), `%B` (BCD: 16*(value/10)+(value%10)), `%n` (exclusive-or all parameters with 0140), `%D` (reverse coding: value-2*(value%16)). Returns output string.
- **`Trequire(@caps)`** — Croaks if any capability is not found.

## Examples
perl
use Term::Cap;

# Get terminal output speed
require POSIX;
my $termios = new POSIX::Termios;
$termios->getattr;
my $ospeed = $termios->getospeed;

# allocate and initialize a terminal structure
$terminal = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed };

# require certain capabilities
$terminal->Trequire(qw/ce ku kd/);

# Output Routines (if $FH undefined, just return string)
$terminal->Tgoto('cm', $col, $row, $FH);
$terminal->Tputs('dl', $count = 1, $FH);
## See Also
- [Term::Cap](https://metacpan.org/pod/Term::Cap)
- termcap man page on Unix-like systems
- [POSIX::Termios](https://perldoc.perl.org/POSIX::Termios)

## Exit Codes
Not documented.