Two Perl modules to handle table

I’ve been using Text::Table to output data onto screen and HTML::QuickTable into HTML file.

Text::Table can output data in table format with or without border which is composed of special characters. Here is an example:

use Text::Table;
my $sep = ' | ';
my $tb = Text::Table->new (\$sep, "Header", \$sep, "Index", \$sep);
my @data;
# ... fill @data
$tb->load (@data);
print $tb->rule('-', '+');
print $tb->title;
print $tb->rule('-', '+');
print $tb->body;
print $tb->rule('-', '+');

If you haven’t used this module, please try it to see what happens by filling dummy data into @data.

HTML::QuickTable is good at generating HTML table or entire HTML file from special data structure with little efforts. For example,

my @body;
while (<>) {
    my @row = split /,/, $_;
    push @body, \@row;
my $qt = HTML::QuickTable->new;
print $qt->render (\@body);

But it gives less control on table layout than HTML::Table. I will not give example since help is written well and its usage is simple.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s