@EXPORT = qw(wrap fill);
@EXPORT_OK = qw($columns $break $huge);
-$VERSION = 2005.0824_01;
+$VERSION = 2006.0711;
use vars qw($VERSION $columns $debug $break $huge $unexpand $tabstop
$separator $separator2);
use re 'taint';
pos($t) = 0;
- while ($t !~ /\G\s*\Z/gc) {
- if ($t =~ /\G([^\n]{0,$ll})($break|\n*\z)/xmgc) {
+ while ($t !~ /\G(?:$break)*\Z/gc) {
+ if ($t =~ /\G([^\n]{0,$ll})($break|\n+|\z)/xmgc) {
$r .= $unexpand
? unexpand($nl . $lead . $1)
: $nl . $lead . $1;
? unexpand($nl . $lead . $1)
: $nl . $lead . $1;
$remainder = defined($separator2) ? $separator2 : $separator;
- } elsif ($huge eq 'overflow' && $t =~ /\G([^\n]*?)($break|\z)/xmgc) {
+ } elsif ($huge eq 'overflow' && $t =~ /\G([^\n]*?)($break|\n+|\z)/xmgc) {
$r .= $unexpand
? unexpand($nl . $lead . $1)
: $nl . $lead . $1;
$remainder = $2;
} elsif ($huge eq 'die') {
die "couldn't wrap '$t'";
+ } elsif ($columns < 2) {
+ warn "Increasing \$Text::Wrap::columns from $columns to 2";
+ $columns = 2;
+ return ($ip, $xp, @t);
} else {
die "This shouldn't happen";
}
$huge = 'overflow';
B<Example 3>
-
+
use Text::Wrap
$Text::Wrap::columns = 72;
paragraphs by looking for whitespace after a newline. In other respects
it acts like wrap().
+Both C<wrap()> and C<fill()> return a single string.
+
=head1 OVERRIDES
C<Text::Wrap::wrap()> has a number of variables that control its behavior.
Historical notes: 'die' used to be the default value of
C<$huge>. Now, 'wrap' is the default value.
-=head1 EXAMPLE
+=head1 EXAMPLES
+
+Code:
+
+ print wrap("\t","",<<END);
+ This is a bit of text that forms
+ a normal book-style indented paragraph
+ END
+
+Result:
+
+ " This is a bit of text that forms
+ a normal book-style indented paragraph
+ "
+
+Code:
+
+ $Text::Wrap::columns=20;
+ $Text::Wrap::separator="|";
+ print wrap("","","This is a bit of text that forms a normal book-style paragraph");
+
+Result:
- print wrap("\t","","This is a bit of text that forms
- a normal book-style paragraph");
+ "This is a bit of|text that forms a|normal book-style|paragraph"
=head1 LICENSE
David Muir Sharnoff <muir@idiom.com> with help from Tim Pierce and
-many many others. Copyright (C) 1996-2002 David Muir Sharnoff.
+many many others. Copyright (C) 1996-2006 David Muir Sharnoff.
This module may be modified, used, copied, and redistributed at
your own risk. Publicly redistributed modified versions must use
a different name.