5 # This is a very simple paragraph formatter. It formats one
6 # paragraph at a time by wrapping and indenting text.
12 # print wrap($initial_tab,$subsequent_tab,@text);
14 # You can also set the number of columns to wrap before:
16 # $Text::Wrap::columns = 135; # <= width of screen
18 # use Text::Wrap qw(wrap $columns);
22 # The first line will be printed with $initial_tab prepended. All
23 # following lines will have $subsequent_tab prepended.
27 # print wrap("\t","","This is a bit of text that ...");
29 # David Muir Sharnoff <muir@idiom.com>
37 @EXPORT_OK = qw($columns);
40 $Text::Wrap::columns = 76; # <= screen width
48 my ($ip, $xp, @t) = @_;
51 my $t = expand(join(" ",@t));
53 my $ll = $Text::Wrap::columns - length(expand($lead)) - 1;
54 if ($t =~ s/^([^\n]{0,$ll})\s//) {
55 $r .= unexpand($lead . $1 . "\n");
57 my $ll = $Text::Wrap::columns - length(expand($lead)) - 1;
58 while ($t =~ s/^([^\n]{0,$ll})\s//) {
59 $r .= unexpand($lead . $1 . "\n");
62 die "couldn't wrap '$t'"