Text::Wrapper - Word wrap text by breaking long lines
This document describes version 1.04 of Text::Wrapper, released May 25, 2012.
require Text::Wrapper; $wrapper = Text::Wrapper->new(columns => 60, body_start => ' '); print $wrapper->wrap($text); $wrapper->columns(70);
Text::Wrapper provides simple word wrapping. It breaks long lines, but does not alter spacing or remove existing line breaks. If you're looking for more sophisticated text formatting, try the Text::Format module.
Reasons to use Text::Wrapper instead of Text::Format:
Again, if Text::Wrapper doesn't meet your needs, try Text::Format.
The text that begins the second and following lines of a paragraph. (Default '')
The number of columns to use. This includes any text in body_start or par_start. (Default 70)
The text that begins the first line of each paragraph. (Default '')
A line can wrap after any of the characters in this string. Setting this to the empty string means a line will wrap only at whitespace. (Default '-')
Returns a word wrapped copy of
$text. The original is not altered.
Text::Wrapper requires no configuration files or environment variables.
Does not handle tabs (they're treated just like spaces).
All characters are treated as being the same width, including zero-width spaces and combining accents.
Does not break words that can't fit on one line.
Christopher J. Madsen
<perl AT cjmweb.net>
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.
You can follow or contribute to Text-Wrapper's development at http://github.com/madsen/text-wrapper.
This software is copyright (c) 2012 by Christopher J. Madsen.
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.