Text::Wrapper - Simple word wrapping routine


Text::Wrapper - Simple word wrapping routine


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


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.


$wrapper = Text::Wrapper->new( [options] )
Constructs a new Text::Wrapper object. The options are specified by key and value. The keys are:
 body_start  The text that begins the second and following lines of
             a paragraph.  (Default '')
 columns     The number of columns to use.  This includes any text
             in body_start or par_start.  (Default 70)
 par_start   The text that begins the first line of each paragraph.
             (Default '')

$wrapper->body_start( [$value] )
$wrapper->columns( [$value] )
$wrapper->par_start( [$value] )
If $value is supplied, sets the option and returns the previous value. If omitted, just returns the current value.

Returns a word wrapped copy of $text. The original is not altered.


Does not handle tabs (they're treated just like spaces).

Does not break words that can't fit on one line.


Christopher J. Madsen <chris_madsen@geocities.com>

 Text::Wrapper - Simple word wrapping routine