man > Data::ShowTable

ShowTable(3pm) User Contributed Perl Documentation ShowTable(3pm)

πŸ“› NAME

ShowTable – routines to display tabular data in several formats.

πŸš€ Quick Reference

Use CaseCommandDescription
πŸ“Š Display a table of data (auto‑mode)ShowTableFormats data in Box, Table, List, or HTML mode
πŸ—„οΈ Show database listShowDatabasesDisplays a single‑column list under β€œDatabases”
πŸ“‹ Show table listShowTablesDisplays a single‑column list under β€œTables”
πŸ›οΈ Show column infoShowColumnsDisplays column names, types, lengths, attributes
πŸ“¦ Box‑style tableShowBoxTableASCII box with +‑‑‑+ borders
πŸ“„ Simple tableShowSimpleTableAligned columns with dashes under headers
🌐 HTML tableShowHTMLTableGenerates <TABLE> with optional hyperlinks
πŸ“‘ List formatShowListTableField:value pairs per row, wrapped
πŸ” Row callbackShowRowFetches rows from arrays for use with ShowTable
πŸ”’ Format a single valueShowTableValueReturns formatted string given value, type, width
🧹 Strip HTMLPlainTextRemoves HTML tags from a string

πŸ“– USAGE

use Data::ShowTable;

ShowTable { parameter => value, ... };
ShowTable \@titles, \@types, \@widths, \&row_sub [, \&fmt_sub ];
ShowDatabases \@dbnames;
ShowDatabases { parameter => value, ... };
ShowTables \@tblnames;
ShowTables { parameter => value, ... };
ShowColumns \@columns, \@col_types, \@col_lengths, \@col_attrs;
ShowColumns { parameter => value, ... };
ShowBoxTable \@titles, \@types, \@widths, \&row_sub [, \&fmt_sub ];
ShowBoxTable { parameter => value, ... };
ShowSimpleTable \@titles, \@types, \@widths, \&row_sub [, \&fmt_sub];
ShowSimpleTable { parameter => value, ... };
ShowHTMLTable \@titles, \@types, \@widths, \&row_sub [, \&fmt_sub];
ShowHTMLTable { parameter => value, ... };
ShowListTable \@titles, \@types, \@widths, \&row_sub [, \&fmt_sub];
ShowListTable { parameter => value, ... };

package Data::ShowTable;
$Show_Mode = 'mode';
$Max_Table_Width = number;
$Max_List_Width = number;
$No_Escape = flag;
%URL_Keys = { "$colname" => "$col_URL", ... };
@Title_Formats = ( fmt1_html, <fmt2_html>, ... );
@Data_Formats = ( fmt1_html, <fmt2_html>, ... );
ShowRow $rewindflag, \$index, $col_array_1 [, $col_array_2, ...;]
$fmt = ShowTableValue $value, $type, $max_width, $width, $precision, $showmode;
[$plaintext = ] PlainText [$htmltext];

πŸ“ DESCRIPTION

The ShowTable module provides subroutines to display tabular data, typically from a database, in nicely formatted columns, in several formats. Its arguments can either be given in a fixed order, or as a single anonymous hash‑array.

The output format for any one invocation can be one of four possible styles:

The subroutines which perform these displays are listed below.

πŸ“¦ EXPORTED NAMES

This module exports the following subroutines:

All of these subroutines are described in detail in the following sections.

πŸ“¦ MODULES

πŸ“Š ShowTable

Format and display the contents of one or more rows of data.

ShowTable { parameter => value, ... };
ShowTable \@titles, \@types, \@widths, \&row_sub [, \&fmt_sub [, $max_width ] [, $show_mode ] ];

The ShowTable subroutine displays tabular data aligned in columns, with headers. It supports four modes: Box, Table, List, and HTML. Arguments may be given as a hashed‑array or fixed‑order arguments plus package‑global variable settings.

Parameter list (hash‑array name / fixed‑order argument / global variable):

πŸ—„οΈ ShowDatabases

Show a list of database names.

ShowDatabases \@dbnames;
ShowDatabases { 'data' => \@dbnames, parameter => value, ...};

Displays a single column under the heading "Databases". A special case of ShowTable.

πŸ“‹ ShowTables

Show an array of table names.

ShowTables \@tblnames;
ShowTables { 'data' => \@tblnames, parameter => value, ...};

Displays a single column under the heading "Tables". A special case of ShowTable.

πŸ›οΈ ShowColumns

Display a table of column names, types, and attributes.

ShowColumns { parameter => values, ... };
ShowColumns \@columns, \@col_types, \@col_lengths, \@col_attrs;

Displays columns, types, lengths, and attributes with headings "Column", "Type", "Length", "Attributes". A special case of ShowTable.

πŸ“¦ ShowBoxTable

Show tabular data in a box.

ShowBoxTable { parameter = value, ... };
ShowBoxTable \@titles, \@types, \@widths, \&row_sub [, [ \&fmt_sub ] [, $max_width ] ];

Displays data in a box of ASCII graphics, e.g.:

+------------+----------+-----+----------+
| Column1    | Column2  | ... | ColumnN  |
+------------+----------+-----+----------+
| Value11    | Value12  | ... | Value 1M |
| Value21    | Value22  | ... | Value 2M |
+------------+----------+-----+----------+

If the @titles array is empty, the header row is omitted.

πŸ“„ ShowSimpleTable

Display a table of data using a simple table format.

ShowSimpleTable \@titles, \@types, \@widths, \&row_sub [, \&fmt_sub];
ShowSimpleTable { parameter => values, ... };

Formats data into a simple table of aligned columns:

Column1  Column2  Column3
-------  -------  -------
Value1   Value2   Value3
Value12  Value22  Value32

Columns are auto‑sized by data widths, plus two spaces between columns. Values too long are wrapped.

🌐 ShowHTMLTable

Display a table of data nicely using HTML tables.

ShowHTMLTable { parameter => value, ... };
ShowHTMLTable \@titles, \@types, \@widths, \&row_sub [, \&fmt_sub [, $max_width [, \%URL_Keys [, $no_escape [, \@title_formats [, \@data_formats [, $table_attrs ] ] ] ] ] ] ];

Additional parameters:

πŸ“‘ ShowListTable

Display a table of data using a list format.

ShowListTable { parameter => value, ... };
ShowListTable \@titles, \@types, \@widths, \&row_sub [, \&fmt_sub [, $max_width [, $wrap_margin ] ] ];

Output example:

Field1_1: Value1_1
Field1_2: Value1_2
<empty line>
Field2_1: Value2_1
Field2_2: Value2_2

πŸ” ShowRow

Fetch rows successively from one or more columns of data.

ShowRow $rewindflag, \$index, $col_array_1 [, $col_array_2, ...];

Designed as a callback for ShowTable. If two or more array references are given, elements selected by $index are returned as the row. If a single array reference is given and each element is an array, the subarray is returned. When $rewindflag is set, the index resets to zero and returns true.

πŸ”’ ShowTableValue

Prepare and return a formatted representation of a value.

$fmt = ShowTableValue $value, $type, $max_width, $width, $precision, $showmode;

🧹 PlainText

$plaintext = &PlainText($htmltext);
&PlainText   # operates on $_

Removes any HTML formatting sequences from the input and returns the plain text.

βš™οΈ VARIABLES

Default values in square brackets:

πŸ”§ INTERNAL SUBROUTINES

πŸ” get_params

my $args = &get_params \@argv, \%params, \@arglist;

Given the original @argv, named parameters %params, and an ordered list of parameter names @arglist, sets the values of each variable. If the only element of @argv is a hash, uses its keys; otherwise uses positional arguments. Returns a HASH reference.

🏷️ html_formats

($prefixes,$suffixes) = html_formats \@html_formats;

Takes an array reference of HTML formatting elements and builds two arrays: prefixes (opening elements) and suffixes (closing elements in reverse order). Each element is a list of HTML elements separated by comma, semicolon, or vertical bar.

πŸ“ calc_widths

($num_cols, $widths, $precision, $max_widths) = &calc_widths( $widthspec, $titles, $rewindable, $row_sub, $fmt_sub, $types, $showmode, $max_width);

Generalized subroutine used by all ShowTable variants to set up column widths, precisions, and maximum widths. Handles scanning of rewindable data for optimal defaults.

Returns: number of columns, array ref of widths, array ref of precisions, array ref of maximum widths.

πŸ“€ putcell

$wrapped = &putcell( \@cells, $c, $cell_width, \@prefix, \@suffix, $wrap_flag );

Outputs the contents of an array cell, wrapping text longer than $cell_width for subsequent calls. Returns non‑zero if wrapping occurred.

🎯 center

$field = center $string, $width;

Center a string within a given width.

πŸ“ˆ max

$max = &max( @values );

Compute the maximum value from a list.

πŸ“‰ min

$min = &min( @values );

Compute the minimum value from a list.

πŸ“ max_length

$maxlength = &max_length( \@array_ref );

Compute the maximum length of strings in an array reference.

πŸ”€ htmltext

$output = &htmltext( $input [, $allflag ] );

Translate regular text for HTML output, escaping "&", ">", "<". If $allflag is non‑zero, all characters are escaped.

πŸ“ out

out $fmt [, @text ];

Print text followed by a newline.

πŸ“ put

put $fmt [, @text ];

Print text without a trailing newline.

πŸ‘€ AUTHOR

Alan K. Stebbens <aks@stebbens.org>

πŸ› BUGS

perl v5.32.0 2021‑01‑06 ShowTable(3pm)

Data::ShowTable
πŸ“› NAME πŸš€ Quick Reference πŸ“– USAGE πŸ“ DESCRIPTION πŸ“¦ EXPORTED NAMES πŸ“¦ MODULES
πŸ“Š ShowTable πŸ—„οΈ ShowDatabases πŸ“‹ ShowTables πŸ›οΈ ShowColumns πŸ“¦ ShowBoxTable πŸ“„ ShowSimpleTable 🌐 ShowHTMLTable πŸ“‘ ShowListTable πŸ” ShowRow πŸ”’ ShowTableValue 🧹 PlainText
βš™οΈ VARIABLES πŸ”§ INTERNAL SUBROUTINES
πŸ” get_params 🏷️ html_formats πŸ“ calc_widths πŸ“€ putcell 🎯 center πŸ“ˆ max πŸ“‰ min πŸ“ max_length πŸ”€ htmltext πŸ“ out πŸ“ put
πŸ‘€ AUTHOR πŸ› BUGS

Generated by phpman v4.9.25-25-g40dbf62 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-14 00:55 @216.73.217.58
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-pro / taotoken.net / www.chedong.com - original format

^_top_^