9 ($a,$b,$c) = split($FS,$_);
11 if (join(';',$a,$b,$c) eq 'a;b;c') {print "ok 1\n";} else {print "not ok 1\n";}
14 if (join("$_",@ary) eq 'aa:b:cc') {print "ok 2\n";} else {print "not ok 2\n";}
17 my @xyz = (@ary = split(//));
18 if (join(".",@ary) eq "a.b.c.\n") {print "ok 3\n";} else {print "not ok 3\n";}
22 if (join(".",@ary) eq "a.b.c") {print "ok 4\n";} else {print "not ok 4\n";}
24 $_ = join(':',split(' '," a b\tc \t d "));
25 if ($_ eq 'a:b:c:d') {print "ok 5\n";} else {print "not ok 5 #$_#\n";}
27 $_ = join(':',split(/ */,"foo bar bie\tdoll"));
28 if ($_ eq "f:o:o:b:a:r:b:i:e:\t:d:o:l:l")
29 {print "ok 6\n";} else {print "not ok 6\n";}
31 $_ = join(':', 'foo', split(/ /,'a b c'), 'bar');
32 if ($_ eq "foo:a:b::c:bar") {print "ok 7\n";} else {print "not ok 7 $_\n";}
34 # Can we say how many fields to split to?
35 $_ = join(':', split(' ','1 2 3 4 5 6', 3));
36 print $_ eq '1:2:3 4 5 6' ? "ok 8\n" : "not ok 8 $_\n";
38 # Can we do it as a variable?
40 $_ = join(':', split(' ','1 2 3 4 5 6', $x));
41 print $_ eq '1:2:3:4 5 6' ? "ok 9\n" : "not ok 9 $_\n";
43 # Does the 999 suppress null field chopping?
44 $_ = join(':', split(/:/,'1:2:3:4:5:6:::', 999));
45 print $_ eq '1:2:3:4:5:6:::' ? "ok 10\n" : "not ok 10 $_\n";
47 # Does assignment to a list imply split to one more field than that?
48 if ($^O eq 'MSWin32') { $foo = `.\\perl -D1024 -e "(\$a,\$b) = split;" 2>&1` }
49 elsif ($^O eq 'VMS') { $foo = `./perl "-D1024" -e "(\$a,\$b) = split;" 2>&1` }
50 else { $foo = `./perl -D1024 -e '(\$a,\$b) = split;' 2>&1` }
51 print $foo =~ /DEBUGGING/ || $foo =~ /SV = (VOID|IV\(3\))/ ? "ok 11\n" : "not ok 11\n";
53 # Can we say how many fields to split to when assigning to a list?
54 ($a,$b) = split(' ','1 2 3 4 5 6', 2);
56 print $_ eq '1:2 3 4 5 6' ? "ok 12\n" : "not ok 12 $_\n";
58 # do subpatterns generate additional fields (without trailing nulls)?
59 $_ = join '|', split(/,|(-)/, "1-10,20,,,");
60 print $_ eq "1|-|10||20" ? "ok 13\n" : "not ok 13\n";
62 # do subpatterns generate additional fields (with a limit)?
63 $_ = join '|', split(/,|(-)/, "1-10,20,,,", 10);
64 print $_ eq "1|-|10||20||||||" ? "ok 14\n" : "not ok 14\n";
66 # is the 'two undefs' bug fixed?
67 (undef, $a, undef, $b) = qw(1 2 3 4);
68 print "$a|$b" eq "2|4" ? "ok 15\n" : "not ok 15\n";
72 local(undef, $a, undef, $b) = qw(1 2 3 4);
73 print "$a|$b" eq "2|4" ? "ok 16\n" : "not ok 16\n";
76 # check splitting of null string
77 $_ = join('|', split(/x/, '',-1), 'Z');
78 print $_ eq "Z" ? "ok 17\n" : "#$_\nnot ok 17\n";
80 $_ = join('|', split(/x/, '', 1), 'Z');
81 print $_ eq "Z" ? "ok 18\n" : "#$_\nnot ok 18\n";
83 $_ = join('|', split(/(p+)/,'',-1), 'Z');
84 print $_ eq "Z" ? "ok 19\n" : "#$_\nnot ok 19\n";
86 $_ = join('|', split(/.?/, '',-1), 'Z');
87 print $_ eq "Z" ? "ok 20\n" : "#$_\nnot ok 20\n";
90 # Are /^/m patterns scanned?
91 $_ = join '|', split(/^a/m, "a b a\na d a", 20);
92 print $_ eq "| b a\n| d a" ? "ok 21\n" : "not ok 21\n# `$_'\n";
94 # Are /$/m patterns scanned?
95 $_ = join '|', split(/a$/m, "a b a\na d a", 20);
96 print $_ eq "a b |\na d |" ? "ok 22\n" : "not ok 22\n# `$_'\n";
98 # Are /^/m patterns scanned?
99 $_ = join '|', split(/^aa/m, "aa b aa\naa d aa", 20);
100 print $_ eq "| b aa\n| d aa" ? "ok 23\n" : "not ok 23\n# `$_'\n";
102 # Are /$/m patterns scanned?
103 $_ = join '|', split(/aa$/m, "aa b aa\naa d aa", 20);
104 print $_ eq "aa b |\naa d |" ? "ok 24\n" : "not ok 24\n# `$_'\n";
108 @ary = split(/\s*:\s*/);
109 if (($res = join(".",@ary)) eq "a.b.c.d") {print "ok 25\n";} else {print "not ok 25\n# res=`$res' != `a.b.c.d'\n";}
111 # use of match result as pattern (!)
112 'p:q:r:s' eq join ':', split('abc' =~ /b/, 'p1q1r1s') or print "not ";
115 # /^/ treated as /^/m
116 $_ = join ':', split /^/, "ab\ncd\nef\n";
117 print "not " if $_ ne "ab\n:cd\n:ef\n";
120 # see if @a = @b = split(...) optimization works
121 @list1 = @list2 = split ('p',"a p b c p");
122 print "not " if @list1 != @list2 or "@list1" ne "@list2"
123 or @list1 != 2 or "@list1" ne "a b c ";
126 # zero-width assertion
127 $_ = join ':', split /(?=\w)/, "rm b";
128 print "not" if $_ ne "r:m :b";
133 @ary = map {ord} split //, v1.20.300.4000.50000.4000.300.20.1;
134 print "not " unless "@ary" eq "1 20 300 4000 50000 4000 300 20 1";
137 @ary = split(/\x{FE}/, "\x{FF}\x{FE}\x{FD}"); # bug id 20010105.016
138 print "not " unless @ary == 2 &&
139 $ary[0] eq "\xFF" && $ary[1] eq "\xFD" &&
140 $ary[0] eq "\x{FF}" && $ary[1] eq "\x{FD}";
143 @ary = split(/(\x{FE}\xFE)/, "\xFF\x{FF}\xFE\x{FE}\xFD\x{FD}"); # variant of 31
144 print "not " unless @ary == 3 &&
145 $ary[0] eq "\xFF\xFF" &&
146 $ary[0] eq "\x{FF}\xFF" &&
147 $ary[0] eq "\x{FF}\x{FF}" &&
148 $ary[1] eq "\xFE\xFE" &&
149 $ary[1] eq "\x{FE}\xFE" &&
150 $ary[1] eq "\x{FE}\x{FE}" &&
151 $ary[2] eq "\xFD\xFD" &&
152 $ary[2] eq "\x{FD}\xFD" &&
153 $ary[2] eq "\x{FD}\x{FD}";
158 my @a = map ord, split(//, join("", map chr, (1234, 123, 2345)));
159 print "not " unless "@a" eq "1234 123 2345";
165 my @a = map ord, split(/$x/, join("", map chr, (1234, 123, 2345)));
166 print "not " unless "@a" eq "1234 2345";
171 # bug id 20000427.003
176 my $sushi = "\x{b36c}\x{5a8c}\x{ff5b}\x{5079}\x{505b}";
178 my @charlist = split //, $sushi;
180 foreach my $ch (@charlist) {
181 $r = $r . " " . sprintf "U+%04X", ord($ch);
184 print "not " unless $r eq " U+B36C U+5A8C U+FF5B U+5079 U+505B";
189 # bug id 20000426.003
191 my $s = "\x20\x40\x{80}\x{100}\x{80}\x40\x20";
193 my ($a, $b, $c) = split(/\x40/, $s);
195 unless $a eq "\x20" && $b eq "\x{80}\x{100}\x{80}" && $c eq $a;
198 my ($a, $b) = split(/\x{100}/, $s);
199 print "not " unless $a eq "\x20\x40\x{80}" && $b eq "\x{80}\x40\x20";
202 my ($a, $b) = split(/\x{80}\x{100}\x{80}/, $s);
203 print "not " unless $a eq "\x20\x40" && $b eq "\x40\x20";
206 my ($a, $b) = split(/\x40\x{80}/, $s);
207 print "not " unless $a eq "\x20" && $b eq "\x{100}\x{80}\x40\x20";
210 my ($a, $b, $c) = split(/[\x40\x{80}]+/, $s);
211 print "not " unless $a eq "\x20" && $b eq "\x{100}" && $c eq "\x20";
218 my $a = "ABC\x{263A}";
220 my @b = split( //, $a );
222 print "not " unless @b == 4;
225 print "not " unless length($b[3]) == 1 && $b[3] eq "\x{263A}";
229 print "not " unless length($a) == 4 && $a eq "ZBC\x{263A}";
234 my @a = split(/\xFE/, "\xFF\xFE\xFD");
236 print "not " unless @a == 2 && $a[0] eq "\xFF" && $a[1] eq "\xFD";