Text::FormatTable3pm
Format text tables
Usage
my $table = Text::FormatTable->new('r|l');$table->head('a', 'b');$table->rule('=');$table->row('c', 'd');print $table->render(20);
Overview
Text::FormatTable renders simple tables as text. You pass to the constructor (new) a table format specification similar to LaTeX (e.g. "r|l|5l|R|20L") and you call methods to fill the table data and insert rules. After the data is filled, you call the render method and the table gets formatted as text.
Methods:
new($format)-
Create a Text::FormatTable object, the format of each column is specified as a character of the
$formatstring. The following formats are defined:- l
-
Left-justified top aligned word-wrapped text.
- L
-
Left-justified bottom aligned word-wrapped text.
- r
-
Right-justified top aligned word-wrapped text.
- R
-
Right-justified bottom aligned word-wrapped text.
- 10R, 20r, 15L, 12l,
-
Number is fixed width of the column. Justified and aligned word-wrapped text (see above).
- ' '
-
A space.
- |
-
Column separator.
head($col1, $col2, ...)-
Add a header row using
$col1,$col2, etc. as cell contents. Note that, at the moment, header rows are treated like normal rows.
row($col1, $col2, ...)-
Add a row with
$col1,$col2, etc. as cell contents.
rule([$char])-
Add an horizontal rule. If
$charis specified it will be used as character to draw the rule, otherwise '-' will be used.
render([$screen_width])-
Return the rendered table formatted with
$screen_widthor 79 if it is not specified.
Code repository
Git - http://github.com/treyharris/Text-FormatTable/tree/master
Releases
11 releases since Debian 3.1 (Sarge); the text changed 5 times.