Front page | perl.modules |
Postings from May 2008
Requesting CPAN Author ID
From:
Shan Leiguang
Date:
May 6, 2008 05:58
Subject:
Requesting CPAN Author ID
Name: 单雷光
Email: shanleiguang@gmail.com
Homepage: http://shanleiguang.googlepages.com
Preferred Author ID: LEIGUANG
I've written a new module called Pretty::Table that I'm planning to put on
CPAN.
*NAME *
Pretty::Table - to print pretty text table
*Example*
use Pretty::Table;
my $pt = Pretty::Table->new(
data_type => 'row', #row mode
data_format => 'ucfirst', #upper char
if_multi_lines => 1, #enable multi-lines mode
max_col_length => 10, #set max_col_length to 10
);
my $dr = [
['id','name','sex','age','email'],
['01','tommy','male',27],
['02','jarry','male',26],
['03','shanleiguang',26,'shanleiguang@gmail.com'],
];
$pt->set_data_ref($dr);
$pt->set_title('Contacts');
$pt->set_align('left');
$pt->set_data_format('ucfirst');
$pt->insert(['05','jackie','male',27,'jakie@somedoain.com']);
$pt->insert(['04','marry','female',26], 4);
print $pt->output();
$pt->set_data_type('col');
$pt->set_deco_cross('*');
$pt->set_if_has_title(0);
print $pt->output();
*Example Output*
+---------------------------------------------+
| Contacts |
+----+------------+--------+-----+------------+
| id | name | sex | age | email |
+----+------------+--------+-----+------------+
| 01 | tommy | male | 27 | |
+----+------------+--------+-----+------------+
| 02 | jarry | male | 26 | |
+----+------------+--------+-----+------------+
| 03 | shanleigua | male | 26 | shanleigua |
| | ng | | | ng@gmail.c |
| | | | | om |
+----+------------+--------+-----+------------+
| 04 | marry | female | 26 | |
+----+------------+--------+-----+------------+
*-------*-------*-------*------------*--------*
| id | 01 | 02 | 03 | 04 |
*-------*-------*-------*------------*--------*
| name | tommy | jarry | shanleigua | marry |
| | | | ng | |
*-------*-------*-------*------------*--------*
| sex | male | male | male | female |
*-------*-------*-------*------------*--------*
| age | 27 | 26 | 26 | 26 |
*-------*-------*-------*------------*--------*
| email | | | shanleigua | |
| | | | ng@gmail.c | |
| | | | om | |
*-------*-------*-------*------------*--------*
-
Requesting CPAN Author ID
by Shan Leiguang