# man > Data::ShowTable

---
type: CommandReference
command: ShowTable
mode: perldoc
section: 3pm
source: perldoc
---

## Quick Reference
- `use Data::ShowTable;` — load the module
- `ShowTable { titles => \@titles, types => \@types, widths => \@widths, row_sub => \&row_sub };` — display tabular data in default mode (Box)
- `ShowBoxTable(\@titles, \@types, \@widths, \&row_sub);` — boxed‑graphics table
- `ShowSimpleTable(\@titles, \@types, \@widths, \&row_sub);` — simple aligned columns
- `ShowHTMLTable { titles => \@titles, types => \@types, widths => \@widths, row_sub => \&row_sub };` — HTML table
- `ShowListTable(\@titles, \@types, \@widths, \&row_sub);` — list‑style name:value pairs
- `ShowDatabases(\@dbnames);` — display database names
- `ShowColumns(\@columns, \@col_types, \@col_lengths, \@col_attrs);` — display column metadata

## Name
`Data::ShowTable` — routines to display tabular data in several formats.

## Synopsis
perl
use Data::ShowTable;

# Hash‑argument style
ShowTable { parameter => value, ... };

# Fixed‑argument style
ShowTable \@titles, \@types, \@widths, \&row_sub [, \&fmt_sub ];

# Variants
ShowBoxTable \@titles, \@types, \@widths, \&row_sub;
ShowSimpleTable \@titles, \@types, \@widths, \&row_sub;
ShowHTMLTable \@titles, \@types, \@widths, \&row_sub;
ShowListTable \@titles, \@types, \@widths, \&row_sub;

# Specialised wrappers
ShowDatabases \@dbnames;
ShowTables \@tblnames;
ShowColumns \@columns, \@col_types, \@col_lengths, \@col_attrs;

# Helper functions
ShowRow $rewindflag, \$index, $col_array_1 [, $col_array_2, ... ];
$fmt = ShowTableValue $value, $type, $max_width, $width, $precision, $showmode;
$plaintext = PlainText $htmltext;
## Options
Common parameters for `ShowTable` and its variants (hash‑argument form):

- `titles => \@titles` — array of column names; empty string for no title, `undef` uses `Field_N`.
- `types => \@types` — array of column types; strings matching `/text|char|string/i` are left‑justified.
- `widths => \@widths` — array of column widths (`N` or `N.P`); zero/null allows auto‑sizing.
- `row_sub => \&row_sub` — subroutine returning next row of data when called with `0`; called with `1` to rewind (returns true if rewindable).
- `fmtsub => \&fmt_sub` — formatting subroutine; defaults to `ShowTableValue`.
- `max_width => $number` — maximum table width (default `$Max_Table_Width`).
- `show_mode => 'Box'|'Table'|'Simple'|'List'|'HTML'` — output style.

Additional parameters for `ShowHTMLTable`:

- `url_keys => \%URL_Keys` — hash mapping column names/indices to URL templates (`%K`, `%V`, `%I`).
- `no_escape => $boolean` — if true, prevents HTML escaping of data (allows embedded HTML).
- `title_formats => \@title_formats` — array of HTML formatting elements per column.
- `data_formats => \@data_formats` — array of HTML formatting elements per data column.
- `table_attrs => $string` — additional `<TABLE>` attributes (e.g., `BORDER=0`).

Additional parameters for `ShowListTable`:

- `wrap_margin => $number` — right‑margin limit before wrapping (default `$List_Wrap_Margin`).

`ShowColumns` specific parameters:

- `columns => \@columns` — column names.
- `col_types => \@col_types` — column types.
- `col_lengths => \@col_lengths` — maximum lengths.
- `col_attrs => \@col_attrs` — array of arrays of attributes.

`ShowDatabases` and `ShowTables` accept a `data` parameter or a single array reference.

Global variables (package `Data::ShowTable`):

- `$Show_Mode` — default display mode (`Box`, `List`, `Table`, `HTML`); overridden by `$ENV{SHOW_MODE}`.
- `$Max_Table_Width` — maximum table width; if set, columns are scaled.
- `$Max_List_Width` — maximum line width in list mode (default `$ENV{COLUMNS}` or 80).
- `$List_Wrap_Margin` — wrap margin in list mode (default 2).
- `$No_Escape` — if true, disables HTML escaping for all HTML tables.
- `%URL_Keys` — default URL keys for HTML mode.
- `@Title_Formats` — default title HTML formats.
- `@Data_Formats` — default data HTML formats.

## Examples
Show a simple table in box mode:

perl
use Data::ShowTable;
my @titles = ('Name', 'Score');
my @types  = ('char', 'int');
my @widths = (10, 5);
my @data = (['Alice', 95], ['Bob', 82]);
my $i = 0;
ShowTable \@titles, \@types, \@widths, sub {
    return () unless $i < @data;
    @{$data[$i++]};
};
Display a database list:

perl
ShowDatabases(['mydb', 'testdb', 'production']);
Show columns with HTML formatting:

perl
ShowHTMLTable {
    titles => ['Name', 'Value'],
    types  => ['char', 'int'],
    widths => [20, 10],
    row_sub => sub { ... },
    url_keys => { Name => 'http://example.com/item?name=%V' },
    title_formats => ['FONT SIZE=+2,BOLD', 'FONT COLOR=red,EM'],
};
List‑style output:

perl
ShowListTable {
    titles => ['Field', 'Value'],
    types  => ['char', 'char'],
    widths => [15, 30],
    row_sub => sub { ... },
    max_width => 60,
    wrap_margin => 5,
};
Using `ShowRow` as a callback:

perl
ShowTable \@titles, \@types, \@widths,
    sub { ShowRow($_[0], \$row_idx, \@col1, \@col2) };
## See Also
- [Data::ShowTable](http://localhost/phpMan.php/perldoc/Data%3A%3AShowTable/markdown)
- [DBI](http://localhost/phpMan.php/perldoc/DBI/markdown)
- [Text::Table](http://localhost/phpMan.php/perldoc/Text%3A%3ATable/markdown)
- [HTML::Table](http://localhost/phpMan.php/perldoc/HTML%3A%3ATable/markdown)