[VPM] Text::Table

Carl B. Constantine cconstan at csc.UVic.CA
Fri Mar 28 15:48:25 CST 2003


Taking nathanael's suggestion to heart, I took a look at some of the
Text:: modules available. Though I can't get to search.cpan.org, I was
able to list some modules by name from the parent cpan.org site. In the
process I found a perl module that may satisfy my needs called
Text::Table.

Text::Table requires Text::Align as a pre-req. Here's an example from
the SYNOPSIS of what Text::Table can do:

use Text::Table;
my $tb = Text::Table->new(
             "Planet", "Radius\nkm", "Density\ng/cm^3"
         );
         $tb->load(
             [ "Mercury", 2360, 3.7 ],
             [ "Venus", 6110, 5.1 ],
             [ "Earth", 6378, 5.52 ],
             [ "Jupiter", 71030, 1.3 ],
         );
         print $tb;

This code results in the following table:

Planet  Radius Density
        km     g/cm^3
Mercury  2360  3.7
Venus    6110  5.1
Earth    6378  5.52
Jupiter 71030  1.3


the Text::Table module supports column alignment such as left, right and
center, as well as num, point (decimal point alignment) and the default
auto.

So, I'm going to try this out and see how well it works. I'll report
back to the list on my findings if anyone is interested.

-- 
Carl B. Constantine         University of Victoria
Programmer Analyst          http://www.csc.uvic.ca
UNIX System Administrator   Victoria, BC, Canada
cconstan at csc.uvic.ca        ELW A220, 721-8753



More information about the Victoria-pm mailing list