Text::Table::Any(3)
๐ Text::Table::Any ๐
okay bestie, meet Text::Table::Any(3) โ yes, thatโs the manual-page name, and itโs hanging out in the User Contributed Perl Documentation section. This thing is literally a table-generating baddie: you hand it rows, it gives you a text table, and it can flex through a whole lineup of backends. no cap. ๐
๐ธ NAME ๐ธ
Text::Table::Any โ generate a text table using one of several backends. periodt โจ
๐ VERSION ๐
This document describes version 0.117 of Text::Table::Any (from Perl distribution Text-Table-Any), released on 2023-11-11. iykyk ๐๏ธ
โจ SYNOPSIS โจ
okay so hereโs the basic slay:
use Text::Table::Any qw/generate_table/;
my $rows = [
# first element is header row
['Distribution', 'Author', 'First Version', 'Latest Version', 'Abstract'],
# subsequent elements are data rows
['ACME-Dzil-Test-daemon', 'DAEMON', '0.001', '0.001', 'Module abstract placeholder text'],
['ACME-Dzil-Test-daemon2', 'DAEMON', '0.001', '0.001', 'Module abstract placeholder text'],
['Acme-CPANModules-ShellCompleters', 'PERLANCAR', '0.001', '0.001', 'Modules that provide shell tab completion for other commands/scripts'],
['Acme-CPANModules-WorkingWithURL', 'PERLANCAR', '0.001', '0.001', 'Working with URL'],
];
print generate_table(rows => $rows);
This will render the table using the default backend Text::Table::Sprintf and print something like:
+----------------------------------+-----------+---------------+----------------+----------------------------------------------------------------------+
| Distribution | Author | First Version | Latest Version | Abstract |
+----------------------------------+-----------+---------------+----------------+----------------------------------------------------------------------+
| ACME-Dzil-Test-daemon | DAEMON | 0.001 | 0.001 | Module abstract placeholder text |
| ACME-Dzil-Test-daemon2 | DAEMON | 0.001 | 0.001 | Module abstract placeholder text |
| Acme-CPANModules-ShellCompleters | PERLANCAR | 0.001 | 0.001 | Modules that provide shell tab completion for other commands/scripts |
| Acme-CPANModules-WorkingWithURL | PERLANCAR | 0.001 | 0.001 | Working with URL |
+----------------------------------+-----------+---------------+----------------+----------------------------------------------------------------------+
To pick another backend:
print generate_table(
rows => $rows,
backend => "Text::Table::Org",
);
The result is something like:
| Distribution | Author | First Version | Latest Version | Abstract |
|----------------------------------+-----------+---------------+----------------+----------------------------------------------------------------------|
| ACME-Dzil-Test-daemon | DAEMON | 0.001 | 0.001 | Module abstract placeholder text |
| ACME-Dzil-Test-daemon2 | DAEMON | 0.001 | 0.001 | Module abstract placeholder text |
| Acme-CPANModules-ShellCompleters | PERLANCAR | 0.001 | 0.001 | Modules that provide shell tab completion for other commands/scripts |
| Acme-CPANModules-WorkingWithURL | PERLANCAR | 0.001 | 0.001 | Working with URL |
To specify some other options:
print generate_table(
rows => $rows,
header_row => 0, # default is true
separate_rows => 1, # default is false
caption => "Some of the new distributions released in Jan 2022",
backend => "Text::Table::Org",
);
The result is something like:
#+CAPTION: Some of the new distributions released in Jan 2022
| Distribution | Author | First Version | Latest Version | Abstract |
|----------------------------------+-----------+---------------+----------------+----------------------------------------------------------------------|
| ACME-Dzil-Test-daemon | DAEMON | 0.001 | 0.001 | Module abstract placeholder text |
|----------------------------------+-----------+---------------+----------------+----------------------------------------------------------------------|
| ACME-Dzil-Test-daemon2 | DAEMON | 0.001 | 0.001 | Module abstract placeholder text |
|----------------------------------+-----------+---------------+----------------+----------------------------------------------------------------------|
| Acme-CPANModules-ShellCompleters | PERLANCAR | 0.001 | 0.001 | Modules that provide shell tab completion for other commands/scripts |
|----------------------------------+-----------+---------------+----------------+----------------------------------------------------------------------|
| Acme-CPANModules-WorkingWithURL | PERLANCAR | 0.001 | 0.001 | Working with URL |
To pass backend-specific options:
print generate_table(
rows => $rows,
backend => "Text::Table::More",
backend_opts => {
border_style => 'ASCII::SingleLineDoubleAfterHeader',
align => 'right',
row_attrs => [
[0, {align=>'middle'}],
],
},
);
The result is something like:
.----------------------------------+-----------+---------------+----------------+----------------------------------------------------------------------.
| Distribution | Author | First Version | Latest Version | Abstract |
+==================================+===========+===============+================+======================================================================+
| ACME-Dzil-Test-daemon | DAEMON | 0.001 | 0.001 | Module abstract placeholder text |
| ACME-Dzil-Test-daemon2 | DAEMON | 0.001 | 0.001 | Module abstract placeholder text |
| Acme-CPANModules-ShellCompleters | PERLANCAR | 0.001 | 0.001 | Modules that provide shell tab completion for other commands/scripts |
| Acme-CPANModules-WorkingWithURL | PERLANCAR | 0.001 | 0.001 | Working with URL |
`----------------------------------+-----------+---------------+----------------+----------------------------------------------------------------------'
๐ฆ DESCRIPTION ๐ฆ
This module gives you one single function, generate_table, and it formats a two-dimensional array of data as a text table using one of several available backends. itโs giving โone function, many fitsโ ๐
The interface is modelled after Text::Table::Tiny, but plot twist: Text::Table::Sprintf is the default backend, and even though Text::Table::Tiny is among the supported backends, it is not required by this module. slay. โจ
๐ DIFFERENCES WITH TEXT::TABLE::TINY ๐
top_and_tailoption fromText::Table::Tinyis not supported โ Probably wonโt be supported. You can pass this option to theText::Table::Tinybackend via thebackend_optsoption. not me reading the fine print ๐styleoption fromText::Table::Tinyis not supported โ Wonโt be supported because this is specific toText::Table::Tiny. If you want custom border styles, here are some alternative backends you can use:Text::ANSITable,Text::Table::TinyBorderStyle,Text::Table::More,Text::UnicodeBox::Table. backend shopping spree ๐indentoption fromText::Table::Tinyis not supported โ Probably wonโt be supported. You can indent a multiline string in Perl using something like:
$rendered_table =~ s/^/ /mg; # indent each line with two spaces
compactoption fromText::Table::Tinyis not supported โ May be supported in the future. future vibes only ๐ฎ
๐ง VARIABLES ๐ง
๐ @BACKENDS
List of supported backends. the whole roster, bestie ๐
๐ฎ %BACKEND_FEATURES
List of features supported by each backend. Hash key is backend name, e.g. "Text::Table::Sprintf". Hash value is a hashref containing feature name as hashref key and a boolean value or other value as hashref value to describe the support of that feature by that backend. feature detective era ๐ต๏ธโโ๏ธ
๐ซถ FUNCTIONS ๐ซถ
๐งธ table
An old name for generate_table function (generate_table() was not available in Text::Table::Tiny < 0.04). This name is not available for export. vintage name, no export ๐ฐ๏ธ
๐ generate_table
Exportable. come get your function โจ
Usage:
table(%params) => str
Except for the backend parameter, the parameters will mostly be passed to the backend, sometimes slightly modified if necessary to achieve the desired effect. If a parameter is not supported by a backend, then it will not be passed to the backend. selective passing, iconic behavior ๐
Known parameters:
backendโ Optional. Str, defaultText::Table::Sprintf. Pick a backend module. Supported backends:Term::TableTerm::TablePrintText::ANSITableText::ASCIITableText::FormatTableText::MarkdownTableText::TableText::Table::ASVText::Table::CSVText::Table::HTMLText::Table::HTML::DataTablesText::Table::LTSVText::Table::ManifoldText::Table::MoreText::Table::OrgText::Table::ParagraphText::Table::SprintfText::Table::TSVText::Table::TickitWidgetText::Table::TinyText::Table::TinyBorderStyleText::Table::TinyColorText::Table::TinyColorWideText::Table::TinyWideText::Table::XLSXText::TabularDisplayText::UnicodeBox::Table
Support matrix for each backend:
Okay so the backend-support matrix is a whole mood, and since tables are banned in this chat weโre doing it as bullets with every single cell intact, no cap. Fields are exactly: backend, align, align_note, backend_opts, backend_opts_note, caption, header_row, rows, separate_rows.
Term::Tableโalign:0;align_note: (empty);backend_opts: (empty);backend_opts_note: (empty);caption:0;header_row:1;rows:1;separate_rows:0.Term::TablePrintโalign:0;align_note: (empty);backend_opts: (empty);backend_opts_note: (empty);caption:0;header_row:1;rows:1;separate_rows:0.Text::ANSITableโalign:1;align_note: (empty);backend_opts: (empty);backend_opts_note: (empty);caption:0;header_row:1;rows:1;separate_rows:1.Text::ASCIITableโalign:1;align_note: (empty);backend_opts: (empty);backend_opts_note: (empty);caption:0;header_row:1;rows:1;separate_rows:0.Text::FormatTableโalign:1;align_note:c(enter) alignment is not supported, will fallback to l(eft);backend_opts: (empty);backend_opts_note: (empty);caption:0;header_row:0;rows:1;separate_rows:0.Text::MarkdownTableโalign:0;align_note: (empty);backend_opts: (empty);backend_opts_note: (empty);caption:0;header_row:1;rows:1;separate_rows:0.Text::Tableโalign:1;align_note: (empty);backend_opts: (empty);backend_opts_note: (empty);caption:0;header_row:0;rows:1;separate_rows:0.Text::Table::ASVโalign:0;align_note: (empty);backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:1;rows:1;separate_rows:0.Text::Table::CSVโalign:0;align_note: (empty);backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:1;rows:1;separate_rows:0.Text::Table::HTMLโalign:0;align_note:TODO, backend does not support yet, parameter already passed;backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:1;header_row:1;rows:1;separate_rows:0.Text::Table::HTML::DataTablesโalign:0;align_note:TODO, backend does not support yet, parameter already passed;backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:1;header_row:1;rows:1;separate_rows:0.Text::Table::LTSVโalign:0;align_note: (empty);backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:0;rows:1;separate_rows:0.Text::Table::Manifoldโalign:1;align_note: (empty);backend_opts: (empty);backend_opts_note: (empty);caption:0;header_row:1;rows:1;separate_rows:0.Text::Table::Moreโalign:1;align_note: (empty);backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:1;rows:1;separate_rows:1.Text::Table::Orgโalign:0;align_note: (empty);backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:1;header_row:1;rows:1;separate_rows:1.Text::Table::Paragraphโalign:0;align_note: (empty);backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:1;rows:1;separate_rows:0.Text::Table::Sprintfโalign:0;align_note: (empty);backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:1;rows:1;separate_rows:1.Text::Table::TSVโalign:0;align_note: (empty);backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:0;rows:1;separate_rows:0.Text::Table::TickitWidgetโalign:0;align_note: (empty);backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:1;rows:1;separate_rows:0.Text::Table::Tinyโalign:1;align_note: (empty);backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:1;rows:1;separate_rows:1.Text::Table::TinyBorderStyleโalign:0;align_note:TODO, backend does not support yet, parameter already passed;backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:1;rows:1;separate_rows:1.Text::Table::TinyColorโalign:0;align_note:TODO, backend does not support yet, parameter already passed;backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:1;rows:1;separate_rows:1.Text::Table::TinyColorWideโalign:0;align_note:TODO, backend does not support yet, parameter already passed;backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:1;rows:1;separate_rows:1.Text::Table::TinyWideโalign:0;align_note:TODO, backend does not support yet, parameter already passed;backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:1;rows:1;separate_rows:1.Text::Table::XLSXโalign:0;align_note: (empty);backend_opts:1;backend_opts_note:Backend-specific options (backend_opts) will be passed to table() or generate_table() directly;caption:0;header_row:1;rows:1;separate_rows:0.Text::TabularDisplayโalign:0;align_note: (empty);backend_opts: (empty);backend_opts_note: (empty);caption:0;header_row:0;rows:1;separate_rows:0.Text::UnicodeBox::Tableโalign:0;align_note:TODO: backend supports left/right;backend_opts: (empty);backend_opts_note: (empty);caption:0;header_row:1;rows:1;separate_rows:0.
Now the option tea, bestie:
rowsโ Required. Itโs an Aoaos (array of array-of-scalars). Each element in the array is a row of data, where each row is an array reference. Periodt.header_rowโ Optional. Bool, default is true. If you give it a true value, the first row in the data gets interpreted as a header row and separated visually from the rest of the table (e.g. with a ruled line). But some backends wonโt display differently.separate_rowsโ Boolean. Optional. Default is false. If set to true, it will draw a separator line after each data row.
Not all backends support this.
captionโ Optional. Str. Caption of the table.alignโ Optional. Array of Str or Str.
This takes an array ref with one entry per column, to specify the alignment of that column. Legal values are 'l', 'c', and 'r' (for left, center, and right, respectively). You can also specify a single alignment for all columns.
Not all backends support this. For example, Text::Table::Sprintf prior to 0.007 does not support this at all. Starting from 0.007, only support left and right alignment.
Note that some backends like Text::ANSITable and Text::Table::More support per-row or per-cell or even conditional alignment. Some backends like Text::ASCIITable and Text::Table can also align beyond just l(eft), c(enter), r(right), e.g. "justify" or align on a decimal point. To do more fine-grained alignment setting, you can use the "backend_opts" parameter.
backend_optsโ Optional. Hashref. Pass backend-specific options to the backend module. Not all backend modules support this, but all backend modules that have interface following"Text::Table::Tiny"should support this. Also note that as the list of common options is expanded, a previously backend-specific option might be available later as a common option.
๐ง backends ๐ง
Return list of supported backends. You can also get the list from the @BACKENDS package variable.
๐ธ HOMEPAGE ๐ธ
Please visit the projectโs homepage at https://metacpan.org/release/Text-Table-Any.
๐ฆ SOURCE ๐ฆ
Source repository is at https://github.com/perlancar/perl-Text-Table-Any.
๐ SEE ALSO ๐
Acme::CPANModules::TextTable
๐ AUTHOR ๐
perlancar <perlancar@cpan.org>
๐ CONTRIBUTING ๐
To contribute, you can send patches by email/via RT, or send pull requests on GitHub.
Most of the time, you donโt need to build the distribution yourself. You can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.
๐ COPYRIGHT AND LICENSE ๐
okay legal era, bestie, but make it cute โ here's the receipts:
This software is copyright (c) 2023, 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015 by perlancar <perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. ๐ซถ
tl;dr: it's free, it's Perl-licensed, go off โ just don't come for perlancar. ๐
๐ BUGS ๐
found a lil glitch? a feature you're obsessed with and simply need? Please report any bugs or feature requests on the bugtracker website:
https://rt.cpan.org/Public/Dist/Display.html?Name=Text-Table-Any
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. fr fr, this is not optional-optional โ a failing test is the whole vibe check and it makes the fix like 100x easier. ๐ญโจ
no test file = the maintainer is just squinting at your description like ๐๏ธ๐๐๏ธ โ give them the receipts!
and that's the whole page, bestie! ๐ you made it to the end, which is honestly iconic of you.
this was Text::Table::Any(3) โ footer says perl v5.42.2, dated 2026-02-15. Screenshot it, cite it, frame it. ๐
go forth and make tables that slay. ๐ โจ๐ฆ
๐ฆ where this page comes from
- alpine 3.24: perl-text-table-any-doc 0.117-r1 ยท GPL-1.0-or-later OR Artistic-1.0-Perl
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms