Re: perlfunc.pod/split; concerning trailing fields
authorFather Chrysostomos <sprout@cpan.org>
Tue, 4 Sep 2007 14:40:24 +0000 (07:40 -0700)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 5 Sep 2007 10:49:06 +0000 (10:49 +0000)
Message-Id: <5A964B87-8725-4BB3-A782-0189B1481113@cpan.org>

p4raw-id: //depot/perl@31793

pod/perlfunc.pod

index 6160508..48478f3 100644 (file)
@@ -5418,14 +5418,22 @@ the following:
 
 produces the output 'h:i: :t:h:e:r:e'.
 
-Empty leading (or trailing) fields are produced when there are positive
-width matches at the beginning (or end) of the string; a zero-width match
-at the beginning (or end) of the string does not produce an empty field.
-For example:
+Empty leading fields are produced when there are positive-width matches at
+the beginning of the string; a zero-width match at the beginning of
+the string does not produce an empty field. For example:
 
    print join(':', split(/(?=\w)/, 'hi there!'));
 
-produces the output 'h:i :t:h:e:r:e!'.
+produces the output 'h:i :t:h:e:r:e!'. Empty trailing fields, on the other
+hand, are produced when there is a match at the end of the string (and
+when LIMIT is given and is not 0), regardless of the length of the match.
+For example:
+
+   print join(':', split(//,   'hi there!', -1));
+   print join(':', split(/\W/, 'hi there!', -1));
+
+produce the output 'h:i: :t:h:e:r:e:!:' and 'hi:there:', respectively,
+both with an empty trailing field.
 
 The LIMIT parameter can be used to split a line partially