split /^/
authorM. J. T. Guy <mjtg@cus.cam.ac.uk>
Tue, 25 Jul 2000 14:18:57 +0000 (15:18 +0100)
committerJarkko Hietaniemi <jhi@iki.fi>
Wed, 26 Jul 2000 04:39:57 +0000 (04:39 +0000)
Message-Id: <E13H4bp-00062h-00@libra.cus.cam.ac.uk>

(with notes from tchrist and gbarr)

p4raw-id: //depot/perl@6441

pod/perlfunc.pod
t/op/split.t

index f449889..5b91dfa 100644 (file)
@@ -4378,6 +4378,9 @@ A C<split> on C</\s+/> is like a C<split(' ')> except that any leading
 whitespace produces a null first field.  A C<split> with no arguments
 really does a C<split(' ', $_)> internally.
 
+A PATTERN of C</^/) is treated as if it were C/^/m), since it isn't
+much use otherwise.
+
 Example:
 
     open(PASSWD, '/etc/passwd');
index 07f0098..58a3113 100755 (executable)
@@ -2,7 +2,7 @@
 
 # $RCSfile: split.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:26 $
 
-print "1..26\n";
+print "1..27\n";
 
 $FS = ':';
 
@@ -113,3 +113,8 @@ if (($res = join(".",@ary)) eq "a.b.c.d") {print "ok 25\n";} else {print "not ok
 # use of match result as pattern (!)
 'p:q:r:s' eq join ':', split('abc' =~ /b/, 'p1q1r1s') or print "no ";
 print "ok 26\n";
+
+# /^/ treated as /^/m
+$_ = join ':', split /^/, "ab\ncd\nef\n";
+print "not " if $_ ne "ab\n:cd\n:ef\n";
+print "ok 27\n";