Text::FormatTable - Format text tables
my $table = Text::FormatTable->new('r|l'); $table->head('a', 'b'); $table->rule('='); $table->row('c', 'd'); print $table->render(20);
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.
r|l|5l|R|20L
Methods:
Create a Text::FormatTable object, the format of each column is specified as a character of the $format string. The following formats are defined:
Left-justified top aligned word-wrapped text.
Left-justified bottom aligned word-wrapped text.
Right-justified top aligned word-wrapped text.
Right-justified bottom aligned word-wrapped text.
Number is fixed width of the column. Justified and aligned word-wrapped text (see above).
A space.
Column separator.
Add a header row using $col1, $col2, etc. as cell contents. Note that, at the moment, header rows are treated like normal rows.
Add a row with $col1, $col2, etc. as cell contents.
Add an horizontal rule. If $char is specified it will be used as character to draw the rule, otherwise '-' will be used.
Return the rendered table formatted with $screen_width or 79 if it is not specified.
Text::ASCIITable
Copyright (c) 2001-2004 Swiss Federal Institute of Technology, Zurich. (c) 2009 Trey Harris All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Git - http://github.com/treyharris/Text-FormatTable/tree/master
David Schweikert <dws@ee.ethz.ch>
Maintained by Trey Harris <treyharris@gmail.com>
Fixed column width and bottom alignment written by Veselin Slavov <vslavov@creditreform.bg>
To install Text::FormatTable, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::FormatTable
CPAN shell
perl -MCPAN -e shell install Text::FormatTable
For more information on module installation, please visit the detailed CPAN module installation guide.