NAME Text::ASCIITable - Create a nice formatted table using ASCII characters. Nice, if you want to output dynamic text to your console or other fixed-size displays. SYNOPSIS use Text::ASCIITable; $t = new Text::ASCIITable; $t->setCols(['Nickname','Name']); $t->addRow('Lunatic-|','Håkon Nessjøen'); $t->addRow('tesepe','William Viker'); $t->addRow('espen','Espen Ursin-Holm'); $t->addRow('mamikk','Martin Mikkelsen'); $t->addRow('p33r','Espen A. Jütte'); print $t->draw(); FUNCTIONS new(options) Initialize a new table. You can specify output-options. For more options, check out the usage for setOptions(name,value) Usage: $t = new Text::ASCIITable; Or with options: $t = new Text::ASCIITable({ hide_Lastline => 1, reportErrors => 0}); setCols(@cols) Define the columns for the table(compare with
before and after the output of this table. draw([@topdesign,@toprow,@middle,@middlerow,@bottom]) All the arrays containing the layout is optional. If you want to make your own "design" to the table, you can do that by giving this method these arrays containing information about which characters to use where. Custom tables The draw method takes "5" arrays of strings to define the layout. The first, third and fifth is LINE layout and the second and fourth is ROW layout. The "fourth" parameter is repeated for each row in the table. $t->draw(, ,
, ,
) LINE Takes an array of "4" strings. For example "['|','|','-','+']" * LEFT - Defines the left chars. May be more than one char. * RIGHT - Defines the right chars. May be more then one char. * LINE - Defines the char used for the line. Must be only one char. * DELIMETER - Defines the char used for the delimeters. Must be only one char. ROW Takes an array of "3" strings. You should not give more than one char to any of these parameters, if you do.. it will probably destroy the output.. Unless you do it with the knowledge of how it will end up. An example: "['|','|','+']" * LEFT - Define the char used for the left side of the table. * RIGHT - Define the char used for the right side of the table. * DELIMETER - Defines the char used for the delimeters. Examples: The easiest way: $t->draw(); Explanatory example: $t->draw( ['L','R','l','D'], # LllllllDllllllR ['L','R','D'], # L info D info R ['L','R','l','D'], # LllllllDllllllR ['L','R','D'], # L info D info R ['L','R','l','D'] # LllllllDllllllR ); Nice example: $t->draw( ['.','.','-','-'], # .-------------. ['|','|','|'], # | info | info | ['|','|','-','-'], # |-------------| ['|','|','|'], # | info | info | [' \\','/ ','_','|'] # \_____|_____/ )); Nice example2: $t->draw( ['.=','=.','-','-'], # .=-----------=. ['|','|','|'], # | info | info | ['|=','=|','-','+'], # |=-----+-----=| ['|','|','|'], # | info | info | ["'=","='",'-','-'] # '=-----------=' )); REQUIRES Exporter, Carp, Text::Wrap AUTHOR Håkon Nessjøen, lunatic@skonux.net VERSION Current version is 0.07. COPYRIGHT Copyright 2002-2003 by Håkon Nessjøen. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.