[perl #33765] [PATCH] perlop: mention why 'print !!0' doesn't
authorSteve Peters <steve@fisharerojo.org>
Wed, 11 May 2005 16:58:22 +0000 (16:58 +0000)
committerAbhijit Menon-Sen <ams@wiw.org>
Wed, 11 May 2005 16:57:27 +0000 (16:57 +0000)
From: Steve Peters via RT <perlbug-followup@perl.org>
Date: 11 May 2005 16:58:22 -0000
Message-Id: <rt-3.0.11-33765-112475.14.5633321030279@perl.org>

Subject: [perl #33766] [PATCH] perldoc -f split lacks basic null example
From: Steve Peters via RT <perlbug-followup@perl.org>
Date: 11 May 2005 17:13:29 -0000
Message-Id: <rt-3.0.11-33766-112476.1.84217630998887@perl.org>

p4raw-id: //depot/perl@24449

pod/perlfunc.pod
pod/perlsyn.pod

index 81a42c2..d7b9bfa 100644 (file)
@@ -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<split>, 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!'));
 
index aabd65d..3d45d55 100644 (file)
@@ -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<undef> are all false in a boolean context. All other values are true.
+Negation of a true value by C<!> or C<not> 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