From: Steve Peters Date: Wed, 11 May 2005 16:58:22 +0000 (+0000) Subject: [perl #33765] [PATCH] perlop: mention why 'print !!0' doesn't X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=52ea55c9ee04ef3b03dd13373eda27b47fea1087;p=p5sagit%2Fp5-mst-13.2.git [perl #33765] [PATCH] perlop: mention why 'print !!0' doesn't From: Steve Peters via RT Date: 11 May 2005 16:58:22 -0000 Message-Id: Subject: [perl #33766] [PATCH] perldoc -f split lacks basic null example From: Steve Peters via RT Date: 11 May 2005 17:13:29 -0000 Message-Id: p4raw-id: //depot/perl@24449 --- diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 81a42c2..d7b9bfa 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -5079,12 +5079,18 @@ produces the output 'h:i:t:h:e:r:e'. Using the empty pattern C specifically matches the null string, and is not be confused with the use of C to mean "the last successful pattern -match". +match". So, for C, the following are equivalent: -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: + print join(':', split(//, 'hi there')); + + print join(':', split('', 'hi there')); + +and they produce 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: print join(':', split(/(?=\w)/, 'hi there!')); diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod index aabd65d..3d45d55 100644 --- a/pod/perlsyn.pod +++ b/pod/perlsyn.pod @@ -105,6 +105,9 @@ as the last item in a statement. The number 0, the strings C<'0'> and C<''>, the empty list C<()>, and C are all false in a boolean context. All other values are true. +Negation of a true value by C or C returns a special false value. +When evaluated as a string it is treated as C<''>, but as a number, it +is treated as 0. =head2 Statement Modifiers