Test::S...m::Table(3)

πŸ“¦
version 1.302027 Β· 2 versions
, in fedora 43

πŸ’– Test::Stream::Table β€” the perl manual page, but make it cute πŸ’–

okay bestie, so this is Test::Stream::Table, from the User Contributed Perl Documentation corner of the perl universe. It's a little module whose whole job is turning a header plus a bunch of rows into an actual formatted table. no cap. πŸŽ€


✨ NAME ✨

Test::Stream::Table β€” format a header and rows into a table 🫢


πŸ’€ DEPRECATED πŸ’€

okay so we need to talk. This distribution is deprecated in favor of Test2, Test2::Suite, and Test2::Workflow. she's retired, she's living her best life, she's not coming back. 😭

if you need to make the switch, go look at Test::Stream::Manual::ToTest2 β€” there's a whole conversion guide waiting for you there. πŸ¦‹


🌸 DESCRIPTION 🌸

so basically this thing gets used by some failing tests to spill the tea about what went wrong β€” diagnostics, you know? and the module is able to generic format rows of data into tables. that's the vibe. that's the whole job. πŸ‘‘


✨ SYNOPSIS ✨

use Test::Stream::Table qw/table/;

my @table = table(
    max_width => 80,
    collapse => 1, # Do not show empty columns
    header => [ 'name', 'age', 'hair color' ],
    rows => [
        [ 'Fred Flinstone',  2000000, 'black' ],
        [ 'Wilma Flinstone', 1999995, 'red' ],
        ...,
    ],
);

# The @table array contains each line of the table, no newlines added.
say $_ for @table;

and this right here prints a table like this:

+-----------------+---------+------------+
| name            | age     | hair color |
+-----------------+---------+------------+
| Fred Flinstone  | 2000000 | black      |
| Wilma Flinstone | 1999995 | red        |
| ...             | ...     | ...        |
+-----------------+---------+------------+

look at those little plus signs holding it all together. iconic. πŸ’…


πŸŽ€ EXPORTS πŸŽ€

@rows = table(...)

the function returns a list of lines, and bestie listen β€” those lines do not have the newline "\n" character appended. you add those yourself, you're grown. πŸ™ˆ

here are the options, one by one, because we don't skip anything in this house:

  • header => [ ... ] β€” if you want a header, specify it here. it takes an arrayref, and each element is that column's heading. πŸ’–
  • rows => [ [...], [...], ... ] β€” this should be an arrayref containing an arrayref per row. rows within rows. it's giving nesting. πŸͺ†
  • collapse => $bool β€” use this if you want ot hide empty columns, that is any column that has no data in any row. heads up: having a header for the column will not effect collapse. so a named-but-empty column is still out here taking up space. 🌈
  • max_width => $num β€” set the maximum width of the table. the table may not be this big, but it will be no bigger. if none is specified it will attempt to fidn the width of your terminal and use that, otherwise it falls back to 80. she tries, okay? πŸ’…
  • sanitize => $bool β€” this will sanitize all the data in the table such that newlines, control characters, and all whitespace except for ASCII 20 ' ' are replaced with escape sequences. this prevents newlines, tabs, and similar whitespace from disrupting the table. no chaos allowed, periodt. 🚫
  • mark_tail => $bool β€” this will replace the last whitespace character of any trailing whitespace with its escape sequence. this makes it easier to notice trailing whitespace when comparing values. so sneaky invisible spaces get a little spotlight. ⭐

🌈 NOTE ON UNICODE/WIDE CHARATERS 🌈

some unicode characters, such as "ε©§" ("U+5A67") are wider than others. these will render just fine if you use utf8; as necessary, and Unicode::GCString is installed, however if the module is not installed there will be anomolies in the table:

+-----+-----+---+
| a   | b   | c |
+-----+-----+---+
| ε©§ | x   | y |
| x   | y   | z |
| x   | ε©§ | z |
+-----+-----+---+

see how the columns are doing a little side-eye? yeah. install the module, bestie. 🧚


πŸ”₯ SOURCE πŸ”₯

the source code repository for Test::Stream can be found at http://github.com/Test-More/Test-Stream/. go be nosy, it's fine. πŸ‘‘


πŸ’œ MAINTAINERS πŸ’œ

  • Chad Granum <exodist@cpan.org>

πŸ’– AUTHORS πŸ’–

  • Chad Granum <exodist@cpan.org>

Copyright 2015 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/


and that's the whole page, bestie. every flag, every default, every repo link, all of it. nothing skipped, nothing invented. 🫢

this was perl v5.42.0 energy, dated 2025-07-25, straight out of the Test::S...m::Table(3) manual page β€” mwah, slay, bye πŸ’…βœ¨

πŸ“¦ where this page comes from