ShowTable(3pm) User Contributed Perl Documentation ShowTable(3pm)
ShowTable β routines to display tabular data in several formats.
| Use Case | Command | Description |
|---|---|---|
| π Display a table of data (autoβmode) | ShowTable | Formats data in Box, Table, List, or HTML mode |
| ποΈ Show database list | ShowDatabases | Displays a singleβcolumn list under βDatabasesβ |
| π Show table list | ShowTables | Displays a singleβcolumn list under βTablesβ |
| ποΈ Show column info | ShowColumns | Displays column names, types, lengths, attributes |
| π¦ Boxβstyle table | ShowBoxTable | ASCII box with +βββ+ borders |
| π Simple table | ShowSimpleTable | Aligned columns with dashes under headers |
| π HTML table | ShowHTMLTable | Generates <TABLE> with optional hyperlinks |
| π List format | ShowListTable | Field:value pairs per row, wrapped |
| π Row callback | ShowRow | Fetches rows from arrays for use with ShowTable |
| π’ Format a single value | ShowTableValue | Returns formatted string given value, type, width |
| π§Ή Strip HTML | PlainText | Removes HTML tags from a string |
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];
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.
This module exports the following subroutines:
ShowDatabases β show list of databasesShowTables β show list of tablesShowColumns β show table of column infoShowTable β show a table of dataShowRow β show a row from one or more columnsShowTableValue β show a single column's valueShowBoxTable β show a table of data in a boxShowListTable β show a table of data in a listShowSimpleTable β show a table of data in a simple tableShowHTMLTable β show a table of data using HTMLPlainText β convert HTML text into plain textAll of these subroutines are described in detail in the following sections.
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):
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.
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.
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.
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.
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.
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:
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
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.
Prepare and return a formatted representation of a value.
$fmt = ShowTableValue $value, $type, $max_width, $width, $precision, $showmode;
$plaintext = &PlainText($htmltext);
&PlainText # operates on $_
Removes any HTML formatting sequences from the input and returns the plain text.
Default values in square brackets:
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.
($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.
($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.
$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.
$field = center $string, $width;
Center a string within a given width.
$max = &max( @values );
Compute the maximum value from a list.
$min = &min( @values );
Compute the minimum value from a list.
$maxlength = &max_length( \@array_ref );
Compute the maximum length of strings in an array reference.
$output = &htmltext( $input [, $allflag ] );
Translate regular text for HTML output, escaping "&", ">", "<". If $allflag is nonβzero, all characters are escaped.
out $fmt [, @text ];
Print text followed by a newline.
put $fmt [, @text ];
Print text without a trailing newline.
Alan K. Stebbens <aks@stebbens.org>
perl v5.32.0 2021β01β06 ShowTable(3pm)
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)
Enhanced by LLM: deepseek-v4-pro / taotoken.net / www.chedong.com - original format