From: Robin Barker Date: Mon, 27 Nov 2000 17:56:44 +0000 (+0000) Subject: Re: 5.6 bug: split /^/ implies /m modifier (from CLPM) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0156e0fd38ee76383c8249624073be2fc80a69a8;p=p5sagit%2Fp5-mst-13.2.git Re: 5.6 bug: split /^/ implies /m modifier (from CLPM) Message-Id: <200011271756.RAA22706@tempest.npl.co.uk> p4raw-id: //depot/perl@7902 --- diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index ec0fe08..f2bf51e 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -4375,6 +4375,15 @@ characters at each point it matches that way. For example: produces the output 'h:i:t:h:e:r:e'. +Empty leading (or trailing) fields are produced when there 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: + + print join(':', split(/(?=\w)/, 'hi there!')); + +produces the output 'h:i :t:h:e:r:e!'. + The LIMIT parameter can be used to split a line partially ($login, $passwd, $remainder) = split(/:/, $_, 3); diff --git a/t/op/split.t b/t/op/split.t index 45df76a..9a6586d 100755 --- a/t/op/split.t +++ b/t/op/split.t @@ -1,6 +1,6 @@ #!./perl -print "1..28\n"; +print "1..29\n"; $FS = ':'; @@ -122,3 +122,8 @@ print "ok 27\n"; print "not " if @list1 != @list2 or "@list1" ne "@list2" or @list1 != 2 or "@list1" ne "a b c "; print "ok 28\n"; + +# zero-width assertion +$_ = join ':', split /(?=\w)/, "rm b"; +print "not" if $_ ne "r:m :b"; +print "ok 29\n";