Text::Wrapper(3)

✨ Text::Wrapper πŸ’…

okay bestie, welcome to Text::Wrapper β€” a lil Perl module from way back (perl v5.42.0 era, 2014-01-26) that word-wraps your text. it's giving minimalist icon behavior and honestly? we're obsessed.


🌸 NAME 🌸

Text::Wrapper β€” word wrap text by breaking long lines. that's it. that's the whole job. slay.


πŸŽ€ VERSION πŸŽ€

no cap, this document describes version 1.05 of Text::Wrapper, released January 18, 2014. vintage but still serving. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole vibe in code, copy it exactly bestie:

require Text::Wrapper;
$wrapper = Text::Wrapper->new(columns => 60, body_start => '    ');
print $wrapper->wrap($text);
$wrapper->columns(70);

like. look at her. four lines and she's already wrapping. main character energy fr fr. ✨


πŸ’œ DESCRIPTION πŸ’œ

Text::Wrapper provides simple word wrapping. she breaks long lines, but β€” and this is the important part, don't skip it β€” she does not alter spacing or remove existing line breaks. she's not here to rearrange your whole life, just to snap the long lines in half. πŸ”₯

if you're looking for more sophisticated text formatting, try the Text::Format module. she's the older, fancier sister with more going on.

reasons to use Text::Wrapper instead of Text::Format (a very real list, bestie):

  • Text::Wrapper is significantly smaller. tiny queen. πŸ‘‘
  • It does not alter existing whitespace or combine short lines. It only breaks long lines. she minds her own business, periodt.

again, if Text::Wrapper doesn't meet your needs, try Text::Format. no hard feelings. 🫢


🌈 ATTRIBUTES 🌈

πŸ“ body_start

the text that begins the second and following lines of a paragraph. (Default: '' β€” so, nothing, she just raw-dogs it)

🧚 columns

the number of columns to use. heads up! this number includes any text in body_start or par_start, so don't forget to budget for your little indents. (Default: 70)

⭐ par_start

the text that begins the first line of each paragraph. (Default: '')

πŸ’… wrap_after

a line can wrap after any of the characters in this string. and here's the twist: setting this to the empty string means a line will wrap only at whitespace. (Default: '-')


πŸ¦„ METHODS πŸ¦„

πŸŽ€ wrap

$wrapper->wrap($text)

returns a word wrapped copy of $text. the original is not altered β€” she's respectful like that. your input stays untouched, the copy gets the glow-up. πŸ’–


🌸 CONFIGURATION AND ENVIRONMENT 🌸

Text::Wrapper requires no configuration files or environment variables. zero setup. plug and play. we love a low-maintenance icon. ✨


πŸ¦‹ DEPENDENCIES πŸ¦‹

none. she's independent. she doesn't need anybody. 🫢


πŸ’€ INCOMPATIBILITIES πŸ’€

none reported. (yet. πŸ‘€)


πŸ™ˆ BUGS AND LIMITATIONS πŸ™ˆ

ok so here's the real talk, bestie β€” these are the things she does not do, and you need to know them:

  • does not handle tabs (they're treated just like spaces). so your tab-indented masterpiece is gonna get flattened. 😭
  • all characters are treated as being the same width, including zero-width spaces and combining accents. yep. she's counting characters, not pixels. it's giving "close enough." ngl.
  • does not break words that can't fit on one line. if a word is just Too Long, she leaves it. she's not gonna slice a word down the middle, that's violence.

πŸ’œ AUTHOR πŸ’œ

Christopher J. Madsen "<perl AT cjmweb.net>" β€” the legend, the icon, the moment.

please report any bugs or feature requests to "<bug-Text-Wrapper AT rt.cpan.org>" or through the web interface at http://rt.cpan.org/Public/Bug/Report.html?Queue=Text-Wrapper. she wants to hear from you fr fr. πŸ’Œ

you can follow or contribute to Text-Wrapper's development at https://github.com/madsen/text-wrapper. go be part of the story. ⭐


this software is copyright (c) 2014 by Christopher J. Madsen.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free as in freedom, bestie. πŸ’–


🌈 DISCLAIMER OF WARRANTY 🌈

ok this part is the Serious Capital Letters part, so no jokes from me β€” copy-pasting it exactly because legal text is not the place for my personality:

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE) EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

and that's the whole page bestie 🫢 this was Text::Wrapper, brought to you by perl v5.42.0 and dated 2014-01-26 β€” now go break some long lines responsibly, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from