This is a temporary fork of Neil Bowen's module to support a method I added to set all of the flags for markdown compatible tables. While waiting on Neil to accept or reject the pull request I wanted Vote::Count to be work on other systems.


Text::Table::Tiny - simple text tables from 2D arrays, with limited templating options


    use Text::Table::Tiny 0.04 qw/ generate_table /;

    my $rows = [
        # header row
        ['Name', 'Rank', 'Serial'],
        # rows
        ['alice', 'pvt', '123456'],
        ['bob',   'cpl', '98765321'],
        ['carol', 'brig gen', '8745'],
    print generate_table(rows => $rows, header_row => 1);


This module provides, generate_table, which formats a two-dimensional array of data as a text table.

A second function generate_markdown_table, formats the table as markdown and should not be passed any other formatting directives.

The example shown in the SYNOPSIS generates the following table:

    | Name  | Rank     | Serial   |
    | alice | pvt      | 123456   |
    | bob   | cpl      | 98765321 |
    | carol | brig gen | 8745     |

NOTE: the interface changed with version 0.04, so if you use the generate_table() function illustrated above, then you need to require at least version 0.04 of this module, as shown in the SYNOPSIS.


The generate_table function understands three arguments, which are passed as a hash.

  • rows

    Takes an array reference which should contain one or more rows of data, where each row is an array reference.

  • header_row

    If given a true value, the first row in the data will be interpreted as a header row, and separated from the rest of the table with a ruled line.

  • separate_rows

    If given a true value, a separator line will be drawn between every row in the table, and a thicker line will be used for the header separator.

  • top_and_tail

    If given a true value, then the top and bottom border lines will be skipped. This reduces the vertical height of the generated table.


Calls generate_table() with all of the settings and parameters necessary to return a table that is valid for most markdown interpreters.

You should not pass or set any other formatting options when using generate_markdown_table.

The first row in the data from rows => will be used as the header row.


If you just pass the data and no other options:

 generate_table(rows => $rows);

You get minimal ruling:

    | Name  | Rank     | Serial   |
    | alice | pvt      | 123456   |
    | bob   | cpl      | 98765321 |
    | carol | brig gen | 8745     |

If you want lines between every row, and also want a separate header:

 generate_table(rows => $rows, header_row => 1, separate_rows => 1);

You get the maximally ornate:

    | Name  | Rank     | Serial   |
    | alice | pvt      | 123456   |
    | bob   | cpl      | 98765321 |
    | carol | brig gen | 8745     |

If you want your table in MarkDown compatible format:

 generate_markdown_table( rows => $rows );

    | Name  | Rank     | Serial   |                 |
    | alice | pvt      | 123456   |
    | bob   | cpl      | 98765321 |
    | carol | brig gen | 8745     |


You can set a number of package variables inside the Text::Table::Tiny package to configure the appearance of the table. This interface is likely to be deprecated in the future, and some other mechanism provided.

  • $Text::Table::Tiny::COLUMN_SEPARATOR = '|';

  • $Text::Table::Tiny::ROW_SEPARATOR = '-';

  • $Text::Table::Tiny::CORNER_MARKER = '+';

  • $Text::Table::Tiny::HEADER_ROW_SEPARATOR = '=';

  • $Text::Table::Tiny::HEADER_CORNER_MARKER = 'O';


Prior to version 0.04 this module provided a function called table(), which wasn't available for export. It took exactly the same arguments:

 use Text::Table::Tiny;
 my $rows = [ ... ];
 print Text::Table::Tiny::table(rows => $rows, separate_rows => 1, header_row => 1);

For backwards compatibility this interface is still supported. The table() function isn't available for export though.


There are many modules for formatting text tables on CPAN. A good number of them are listed in the See Also section of the documentation for Text::Table::Manifold.




Creighton Higgins <chiggins@chiggins.com>

Now maintained by Neil Bowers <neilb@cpan.org>


This software is copyright (c) 2012 by Creighton Higgins.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.