From 129772121ba805581760891290010aa8aebb17c1 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Tue, 4 Sep 2007 07:40:24 -0700 Subject: [PATCH] Re: perlfunc.pod/split; concerning trailing fields Message-Id: <5A964B87-8725-4BB3-A782-0189B1481113@cpan.org> p4raw-id: //depot/perl@31793 --- pod/perlfunc.pod | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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 -- 2.7.4