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 setCols(@cols) Define the columns for the table(compare with in HTML). For example "setCols(['Id','Nick','Name'])". Note that you cannot add Cols after you have added a row. addCol($col) Add a column to the columnlist. This still can't be done after you have added a row. addRow(@collist) Adds one row to the table. This must be an array of strings. If you defined 3 columns. This array must have 3 items in it. And so on. Should be self explanatory. alignColRight($col) Given a columnname, it aligns all data to the right in the table. This looks nice on numerical displays in a column. The column names in the table will not be unaffected by the alignment. getTableWidth() If you need to know how wide your table will be before you draw it. Use this function. 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 AUTHOR Håkon Nessjøen, lunatic@skonux.net 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.