1Text::Table::Tiny(3)  User Contributed Perl Documentation Text::Table::Tiny(3)
2
3
4

NAME

6       Text::Table::Tiny - simple text tables from 2D arrays, with limited
7       templating options
8

SYNOPSIS

10           use Text::Table::Tiny 0.04 qw/ generate_table /;
11
12           my $rows = [
13               # header row
14               ['Name', 'Rank', 'Serial'],
15               # rows
16               ['alice', 'pvt', '123456'],
17               ['bob',   'cpl', '98765321'],
18               ['carol', 'brig gen', '8745'],
19           ];
20           print generate_table(rows => $rows, header_row => 1);
21

DESCRIPTION

23       This module provides a single function, "generate_table", which formats
24       a two-dimensional array of data as a text table.
25
26       The example shown in the SYNOPSIS generates the following table:
27
28           +-------+----------+----------+
29           | Name  | Rank     | Serial   |
30           +-------+----------+----------+
31           | alice | pvt      | 123456   |
32           | bob   | cpl      | 98765321 |
33           | carol | brig gen | 8745     |
34           +-------+----------+----------+
35
36       NOTE: the interface changed with version 0.04, so if you use the
37       "generate_table()" function illustrated above, then you need to require
38       at least version 0.04 of this module, as shown in the SYNOPSIS.
39
40   generate_table()
41       The "generate_table" function understands three arguments, which are
42       passed as a hash.
43
44       ·   rows
45
46           Takes an array reference which should contain one or more rows of
47           data, where each row is an array reference.
48
49       ·   header_row
50
51           If given a true value, the first row in the data will be
52           interpreted as a header row, and separated from the rest of the
53           table with a ruled line.
54
55       ·   separate_rows
56
57           If given a true value, a separator line will be drawn between every
58           row in the table, and a thicker line will be used for the header
59           separator.
60
61       ·   top_and_tail
62
63           If given a true value, then the top and bottom border lines will be
64           skipped.  This reduces the vertical height of the generated table.
65
66   EXAMPLES
67       If you just pass the data and no other options:
68
69        generate_table(rows => $rows);
70
71       You get minimal ruling:
72
73           +-------+----------+----------+
74           | Name  | Rank     | Serial   |
75           | alice | pvt      | 123456   |
76           | bob   | cpl      | 98765321 |
77           | carol | brig gen | 8745     |
78           +-------+----------+----------+
79
80       If you want lines between every row, and also want a separate header:
81
82        generate_table(rows => $rows, header_row => 1, separate_rows => 1);
83
84       You get the maximally ornate:
85
86           +-------+----------+----------+
87           | Name  | Rank     | Serial   |
88           O=======O==========O==========O
89           | alice | pvt      | 123456   |
90           +-------+----------+----------+
91           | bob   | cpl      | 98765321 |
92           +-------+----------+----------+
93           | carol | brig gen | 8745     |
94           +-------+----------+----------+
95

FORMAT VARIABLES

97       You can set a number of package variables inside the
98       "Text::Table::Tiny" package to configure the appearance of the table.
99       This interface is likely to be deprecated in the future, and some other
100       mechanism provided.
101
102       ·   $Text::Table::Tiny::COLUMN_SEPARATOR = '|';
103
104       ·   $Text::Table::Tiny::ROW_SEPARATOR = '-';
105
106       ·   $Text::Table::Tiny::CORNER_MARKER = '+';
107
108       ·   $Text::Table::Tiny::HEADER_ROW_SEPARATOR = '=';
109
110       ·   $Text::Table::Tiny::HEADER_CORNER_MARKER = 'O';
111

PREVIOUS INTERFACE

113       Prior to version 0.04 this module provided a function called "table()",
114       which wasn't available for export. It took exactly the same arguments:
115
116        use Text::Table::Tiny;
117        my $rows = [ ... ];
118        print Text::Table::Tiny::table(rows => $rows, separate_rows => 1, header_row => 1);
119
120       For backwards compatibility this interface is still supported.  The
121       "table()" function isn't available for export though.
122

SEE ALSO

124       There are many modules for formatting text tables on CPAN.  A good
125       number of them are listed in the See Also
126       <https://metacpan.org/pod/Text::Table::Manifold#See-Also> section of
127       the documentation for Text::Table::Manifold.
128

REPOSITORY

130       <https://github.com/neilb/Text-Table-Tiny>
131

AUTHOR

133       Creighton Higgins <chiggins@chiggins.com>
134
135       Now maintained by Neil Bowers <neilb@cpan.org>
136
138       This software is copyright (c) 2012 by Creighton Higgins.
139
140       This is free software; you can redistribute it and/or modify it under
141       the same terms as the Perl 5 programming language system itself.
142
143
144
145perl v5.30.1                      2020-01-30              Text::Table::Tiny(3)
Impressum