[PerlChina] 写了个模块Pretty::Table,请大家测试

bruce cheng bruce1914 at gmail.com
Wed May 7 07:07:10 PDT 2008


哈哈 ,文字版的SQL

> -----Original Message-----
> From: china-pm-bounces+bruce1914=gmail.com at pm.org [mailto:china-pm-
> bounces+bruce1914=gmail.com at pm.org] On Behalf Of joe jiang
> Sent: 2008年5月7日 22:05
> To: china-pm at pm.org
> Subject: Re: [PerlChina] 写了个模块Pretty::Table,请大家测试
> 
> 很酷的纵向列表哦 :D
> 
> On 三, 2008-05-07 at 20:54 +0800, Shan Leiguang wrote:
> > 写了个模块Pretty::Table,可以打印比较漂亮的格式对齐的文本表格,可用于
> > 生成文本报表或日志文件,请大家测试,欢迎反馈你的意见和建议。
> >
> >
> >
> > =head1 Example
> >
> >     use Pretty::Table;
> >
> >     my $pt = Pretty::Table->new(
> >         data_type      => 'row',     #row mode
> >         data_format    => 'ucfirst', #uppercase the first 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'], #this is a row
> >         ['01','tommy','male',27],
> >         ['02','jarry','male',26],
> >         ['03','shanleiguang',26,'shanleiguang at gmail.com'],
> >     ];
> >
> >     $pt->set_data_ref($dr);
> >     $pt->set_title('Contacts');
> >     $pt->set_align('left');
> >     $pt->set_data_format('normal');
> >     $pt->insert(['04','marry','female',26], 4);
> >     $pt->sort_by('name');
> >     print $pt->output();
> >
> >     $pt->set_data_type('col'); #change to 'col' mode
> >     $pt->set_deco_cross('*');
> >     $pt->set_if_has_title(0);
> >     print $pt->output();
> >
> > =head1 Example Output
> >
> >   +---------------------------------------------+
> >   | Contacts                                    |
> >   +----+------------+--------+-----+------------+
> >   | id | name       | sex    | age | email      |
> >   +----+------------+--------+-----+------------+
> >   | 01 | tommy      | male   | 27  |            |
> >   +----+------------+--------+-----+------------+
> >   | 02 | jarry      | male   | 26  |            |
> >   +----+------------+--------+-----+------------+
> >   | 03 | shanleigua | male   | 26  | shanleigua |
> >   |    | ng         |        |     | ng at 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 at gmail.c |        |
> >   |       |       |       | om         |        |
> >   *-------*-------*-------*------------*--------*
> >
> > _______________________________________________
> > China-pm mailing list
> > China-pm at pm.org
> > http://mail.pm.org/mailman/listinfo/china-pm
> 
> _______________________________________________
> China-pm mailing list
> China-pm at pm.org
> http://mail.pm.org/mailman/listinfo/china-pm



More information about the China-pm mailing list