1Text::Wrapper(3) User Contributed Perl Documentation Text::Wrapper(3)
2
3
4
6 Text::Wrapper - Simple word wrapping routine
7
9 require Text::Wrapper;
10 $wrapper = Text::Wrapper->new(columns => 60, body_start => ' ');
11 print $wrapper->wrap($text);
12
14 Text::Wrapper provides simple word wrapping. It breaks long lines, but
15 does not alter spacing or remove existing line breaks. If you're look‐
16 ing for more sophisticated text formatting, try the Text::Format mod‐
17 ule.
18
19 Reasons to use Text::Wrapper instead of Text::Format:
20
21 · Text::Wrapper is significantly smaller.
22
23 · It does not alter existing whitespace or combine short lines. It
24 only breaks long lines.
25
26 Again, if Text::Wrapper doesn't meet your needs, try Text::Format.
27
28 Methods
29
30 $wrapper = Text::Wrapper->new( [options] )
31 Constructs a new Text::Wrapper object. The options are specified
32 by key and value. The keys are:
33
34 body_start The text that begins the second and following lines of
35 a paragraph. (Default '')
36
37 columns The number of columns to use. This includes any text
38 in body_start or par_start. (Default 70)
39
40 par_start The text that begins the first line of each paragraph.
41 (Default '')
42
43 $wrapper->body_start( [$value] )
44 $wrapper->columns( [$value] )
45 $wrapper->par_start( [$value] )
46 If $value is supplied, sets the option and returns the previous
47 value. If omitted, just returns the current value.
48
49 $wrapper->wrap($text)
50 Returns a word wrapped copy of $text. The original is not altered.
51
53 Does not handle tabs (they're treated just like spaces).
54
55 Does not break words that can't fit on one line.
56
58 Text::Wrapper is distributed under the same terms as Perl itself.
59
60 This means it is distributed in the hope that it will be useful, but
61 without any warranty; without even the implied warranty of mer‐
62 chantability or fitness for a particular purpose. See the GNU General
63 Public License or the Artistic License for more details.
64
66 Christopher J. Madsen <perl AT cjmweb.net>
67
68 Please send bug reports to bug-Text-Wrapper AT rt.cpan.org, or use the
69 web interface at <http://rt.cpan.org/Pub‐
70 lic/Bug/Report.html?Queue=Text-Wrapper>
71
72
73
74perl v5.8.8 2008-02-04 Text::Wrapper(3)