@EXPORT = qw(expand unexpand $tabstop);
use vars qw($VERSION $tabstop $debug);
-$VERSION = 96.051501;
+$VERSION = 96.121201;
use strict;
/sex;
}
return @l if wantarray;
- return @l[0];
+ return $l[0];
}
sub unexpand
$x = join("\n", @lines);
}
return @l if wantarray;
- return @l[0];
+ return $l[0];
}
1;
=head1 NAME
-Text::Tabs - expand and unexpand tabs per the unix expand(1) and unexpand(1)
+Text::Tabs -- expand and unexpand tabs per the unix expand(1) and unexpand(1)
=head1 SYNOPSIS
- use Text::Tabs;
+use Text::Tabs;
- $tabstop = 4;
- @lines_without_tabs = expand(@lines_with_tabs);
- @lines_with_tabs = unexpand(@lines_without_tabs);
+$tabstop = 4;
+@lines_without_tabs = expand(@lines_with_tabs);
+@lines_with_tabs = unexpand(@lines_without_tabs);
=head1 DESCRIPTION
=head1 AUTHOR
-David Muir Sharnoff E<lt>F<muir@idiom.com>E<gt>
+David Muir Sharnoff <muir@idiom.com>
$VERSION = 96.041801;
use vars qw($VERSION $columns $debug);
+use strict;
BEGIN {
$columns = 76; # <= screen width
}
use Text::Tabs;
-use strict;
sub wrap
{
return $r;
}
+
1;
__DATA__
=head1 DESCRIPTION
-Text::Wrap is a very simple paragraph formatter. It formats a
+Text::Wrap::wrap() is a very simple paragraph formatter. It formats a
single paragraph at a time by breaking lines at word boundries.
Indentation is controlled for the first line ($initial_tab) and
all subsquent lines ($subsequent_tab) independently. $Text::Wrap::columns
=head1 AUTHOR
-David Muir Sharnoff E<lt>F<muir@idiom.com>E<gt>
+David Muir Sharnoff <muir@idiom.com> with help from Tim Pierce and
+others.
=cut
+
+ print fill($initial_tab, $subsequent_tab, @text);
+
+ print fill("", "", `cat book`);
+
+Text::Wrap::fill() is a simple multi-paragraph formatter. It formats
+each paragraph separately and then joins them together when it's done. It
+will destory any whitespace in the original text. It breaks text into
+paragraphs by looking for whitespace after a newline. In other respects
+it acts like wrap().
+
+# Tim Pierce did a faster version of this:
+
+sub fill
+{
+ my ($ip, $xp, @raw) = @_;
+ my @para;
+ my $pp;
+
+ for $pp (split(/\n\s+/, join("\n",@raw))) {
+ $pp =~ s/\s+/ /g;
+ my $x = wrap($ip, $xp, $pp);
+ push(@para, $x);
+ }
+
+ # if paragraph_indent is the same as line_indent,
+ # separate paragraphs with blank lines
+
+ return join ($ip eq $xp ? "\n\n" : "\n", @para);
+}
+