logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Text::SimpleTable - Simple Eyecandy ASCII Tables

Author

       Sebastian Riedel, "sri@cpan.org".

Credits

       In alphabetical order:

       Brian Cassidy

Description

       Simple eyecandy ASCII tables.

Maintainer

       Marcus Ramberg "mramberg@cpan.org".

Methods

       Text::SimpleTable implements the following methods.

   "new"
           my $t = Text::SimpleTable->new(5, 10);
           my $t = Text::SimpleTable->new([5, 'Col1', 10, 'Col2']);

   "draw"
           my $ascii = $t->draw;

   "hr"
           $t = $t->hr;

   "row"
           $t = $t->row('col1 data', 'col2 data');

   "boxes"
           $t = $t->boxes;

       "boxes" switches the output generated by "draw" to use the unicode box drawing characters. The last
       example above may not render nicely on some devices.

Name

       Text::SimpleTable - Simple Eyecandy ASCII Tables

Synopsis

           use Text::SimpleTable;

           my $t1 = Text::SimpleTable->new(5, 10);
           $t1->row('foobarbaz', 'yadayadayada');
           print $t1->draw;

           .-------+------------.
           | foob- | yadayaday- |
           | arbaz | ada        |
           '-------+------------'

           my $t2 = Text::SimpleTable->new([5, 'Foo'], [10, 'Bar']);
           $t2->row('foobarbaz', 'yadayadayada');
           $t2->row('barbarbarbarbar', 'yada');
           print $t2->draw;

           .-------+------------.
           | Foo   | Bar        |
           +-------+------------+
           | foob- | yadayaday- |
           | arbaz | ada        |
           | barb- | yada       |
           | arba- |            |
           | rbar- |            |
           | bar   |            |
           '-------+------------'

           my $t3 = Text::SimpleTable->new([5, 'Foo'], [10, 'Bar']);
           $t3->row('foobarbaz', 'yadayadayada');
           $t3->hr;
           $t3->row('barbarbarbarbar', 'yada');
           print $t3->draw;

           .-------+------------.
           | Foo   | Bar        |
           +-------+------------+
           | foob- | yadayaday- |
           | arbaz | ada        |
           +-------+------------+
           | barb- | yada       |
           | arba- |            |
           | rbar- |            |
           | bar   |            |
           '-------+------------'

           print $t3->boxes->draw;

           ┌───────┬────────────┐
           │ Foo   │ Bar        │
           ├───────┼────────────┤
           │ foob- │ yadayaday- │
           │ arbaz │ ada        │
           ├───────┼────────────┤
           │ barb- │ yada       │
           │ arba- │            │
           │ rbar- │            │
           │ bar   │            │
           └───────┴────────────┘

See Also