1Text::Wrapper(3) User Contributed Perl Documentation Text::Wrapper(3)
2
3
4
6 Text::Wrapper - Simple word wrapping routine
7
9 This document describes version 1.02 of Text::Wrapper, released May 10,
10 2008.
11
13 require Text::Wrapper;
14 $wrapper = Text::Wrapper->new(columns => 60, body_start => ' ');
15 print $wrapper->wrap($text);
16
18 Text::Wrapper provides simple word wrapping. It breaks long lines, but
19 does not alter spacing or remove existing line breaks. If you're
20 looking for more sophisticated text formatting, try the Text::Format
21 module.
22
23 Reasons to use Text::Wrapper instead of Text::Format:
24
25 · Text::Wrapper is significantly smaller.
26
27 · It does not alter existing whitespace or combine short lines. It
28 only breaks long lines.
29
30 Again, if Text::Wrapper doesn't meet your needs, try Text::Format.
31
32 Methods
33 $wrapper = Text::Wrapper->new( [options] )
34 Constructs a new Text::Wrapper object. The options are specified
35 by key and value. The keys are:
36
37 body_start The text that begins the second and following lines of
38 a paragraph. (Default '')
39
40 columns The number of columns to use. This includes any text
41 in body_start or par_start. (Default 70)
42
43 par_start The text that begins the first line of each paragraph.
44 (Default '')
45
46 $wrapper->body_start( [$value] )
47 $wrapper->columns( [$value] )
48 $wrapper->par_start( [$value] )
49 If $value is supplied, sets the option and returns the previous
50 value. If omitted, just returns the current value.
51
52 $wrapper->wrap($text)
53 Returns a word wrapped copy of $text. The original is not altered.
54
56 None.
57
59 None reported.
60
62 Does not handle tabs (they're treated just like spaces).
63
64 Does not break words that can't fit on one line.
65
67 Christopher J. Madsen C<< <perl AT cjmweb.net> >>
68
69 Please report any bugs or feature requests to
70 C<< <bug-Text-Wrapper AT rt.cpan.org> >>, or through the web interface
71 at http://rt.cpan.org/Public/Bug/Report.html?Queue=Text-Wrapper
72 <http://rt.cpan.org/Public/Bug/Report.html?Queue=Text-Wrapper>
73
75 Copyright 1998 Christopher J. Madsen
76
77 Text::Wrapper is free software; you can redistribute it and/or modify
78 it under the same terms as Perl itself.
79
81 BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
82 FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT
83 WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER
84 PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND,
85 EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
86 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
87 ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
88 YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
89 NECESSARY SERVICING, REPAIR, OR CORRECTION.
90
91 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
92 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
93 REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE
94 TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR
95 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
96 SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
97 RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
98 FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
99 SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
100 DAMAGES.
101
102
103
104perl v5.12.0 2010-05-07 Text::Wrapper(3)