From: Father Chrysostomos Date: Tue, 4 Sep 2007 14:40:24 +0000 (-0700) Subject: Re: perlfunc.pod/split; concerning trailing fields X-Git-Tag: accepted/trunk/20130322.191538~14691 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=129772121ba805581760891290010aa8aebb17c1;p=platform%2Fupstream%2Fperl.git Re: perlfunc.pod/split; concerning trailing fields Message-Id: <5A964B87-8725-4BB3-A782-0189B1481113@cpan.org> p4raw-id: //depot/perl@31793 --- diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 6160508..48478f3 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -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