- SEE ALSO
- COPYRIGHT AND LICENSE
Text::Table::Sprintf - Generate simple text tables from 2D arrays using sprintf()
This document describes version 0.001 of Text::Table::Sprintf (from Perl distribution Text-Table-Sprintf), released on 2020-08-10.
use Text::Table::Sprintf; my $rows = [ # header row ['Name', 'Rank', 'Serial'], # rows ['alice', 'pvt', '123456'], ['bob', 'cpl', '98765321'], ['carol', 'brig gen', '8745'], ]; print Text::Table::Sprintf::table(rows => $rows, header_row => 1);
This module provides a single function,
table, which formats a two-dimensional array of data as a simple text table.
The example shown in the SYNOPSIS generates the following table:
+-------+----------+----------+ | Name | Rank | Serial | +-------+----------+----------+ | alice | pvt | 123456 | | bob | cpl | 98765321 | | carol | brig gen | 8745 | +-------+----------+----------+
This module models its interface on Text::Table::Tiny 0.03, employs the same technique of using
sprintf(), but takes the technique further by using a single large format and
sprintf the whole table. This results in even more performance gain (see benchmark result or benchmark using Acme::CPANModules::TextTable).
Caveats: make sure each row contains the same number of elements. Otherwise, the table will not be correctly formatted (cells might move to another row/column).
my $table_str = Text::Table::Sprintf::table(%params);
table function understands these arguments, which are passed as a hash.
Takes an array reference which should contain one or more rows of data, where each row is an array reference.
If given a true value, the first row in the data will be interpreted as a header row, and separated from the rest of the table with a ruled line.
Please visit the project's homepage at https://metacpan.org/release/Text-Table-Sprintf.
Source repository is at https://github.com/perlancar/perl-Text-Table-Sprintf.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Text-Table-Sprintf
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.
Other text table modules listed in Acme::CPANModules::TextTable.
This software is copyright (c) 2020 by email@example.com.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.