Text::...atTable(3pm)

πŸ“¦
version 1.03 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

Text::FormatTable β€” bestie, it formats text tables πŸ’– (and yeah, this page lives in the User Contributed Perl Documentation part of the Text::...atTable(3pm) manpage, so you're in the right place 🫢)


🌸 SYNOPSIS 🌸

my $table = Text::FormatTable->new('r|l');
$table->head('a', 'b');
$table->rule('=');
$table->row('c', 'd');
print $table->render(20);

πŸ’… DESCRIPTION πŸ’…

Okay so here's the vibe: Text::FormatTable renders simple tables as text. You hand the constructor (new) a table format spec that's giving very LaTeX, like "r|l|5l|R|20L", and then you call methods to fill in the table data and drop in rules. Once all the data is in, you call the render method and boom β€” your table gets formatted as text. Iconic behavior fr fr ✨

Methods, let's go:

πŸŽ€ new($format)

Create a Text::FormatTable object. The format of each column is specified as a character of the $format string. The following formats are defined:

  • l β€” Left-justified, top aligned, word-wrapped text.
  • L β€” Left-justified, bottom aligned, word-wrapped text.
  • r β€” Right-justified, top aligned, word-wrapped text.
  • R β€” Right-justified, bottom aligned, word-wrapped text.
  • 10R, 20r, 15L, 12l β€” the number is the fixed width of the column. Justified and aligned word-wrapped text (see above πŸ‘†). So like, number + letter = fixed width + alignment combo, iykyk.
  • ' ' β€” a space. Literally just a space 🫧
  • | β€” column separator.

πŸ¦‹ head($col1, $col2, ...)

Add a header row using $col1, $col2, etc. as cell contents. Heads up bestie: at the moment, header rows are treated like normal rows. No special treatment, no cap πŸ’€

πŸ“ row($col1, $col2, ...)

Add a row with $col1, $col2, etc. as cell contents.

πŸ’œ rule([$char])

Add a horizontal rule. If $char is specified, it's used as the character to draw the rule with. Otherwise - gets used. Cute divider energy, but make it your own character ✨

πŸ‘‘ render([$screen_width])

Return the rendered table, formatted with $screen_width β€” or 79 if it isn't specified. Default queen behavior πŸ’…


🌈 SEE ALSO 🌈

  • Text::ASCIITable

Copyright (c) 2001-2004 Swiss Federal Institute of Technology, Zurich. (c) 2009 Trey Harris All Rights Reserved.

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


🧚 CODE REPOSITORY 🧚

Git - http://github.com/treyharris/Text-FormatTable/tree/master


πŸ’– AUTHOR πŸ’–

David Schweikert <dws@ee.ethz.ch>

Maintained by Trey Harris <treyharris@gmail.com>

Fixed column width and bottom alignment written by Veselin Slavov <vslavov@creditreform.bg>


Okay that's the whole page, bestie, no notes, we ate 🍽️✨ This one came from perl v5.36.0, dated 2022-11-20, in the Text::...atTable(3pm) manpage β€” go format some tables, you got this πŸ’…πŸ’–

πŸ“¦ where this page comes from