Lines Matching refs:split

16 ($a,$b,$c) = split($FS,$_);
20 @ary = split(/:b:/);
21 $cnt = split(/:b:/);
26 my @xyz = (@ary = split(//));
27 $cnt = split(//);
32 @ary = split(/:/);
33 $cnt = split(/:/);
37 $_ = join(':',split(' '," a b\tc \t d "));
39 @ary = split(' '," a b\tc \t d ");
40 $cnt = split(' '," a b\tc \t d ");
43 $_ = join(':',split(/ */,"foo bar bie\tdoll"));
45 @ary = split(/ */,"foo bar bie\tdoll");
46 $cnt = split(/ */,"foo bar bie\tdoll");
49 $_ = join(':', 'foo', split(/ /,'a b c'), 'bar');
51 @ary = split(/ /,'a b c');
52 $cnt = split(/ /,'a b c');
55 # Can we say how many fields to split to?
56 $_ = join(':', split(' ','1 2 3 4 5 6', 3));
58 @ary = split(' ','1 2 3 4 5 6', 3);
59 $cnt = split(' ','1 2 3 4 5 6', 3);
64 $_ = join(':', split(' ','1 2 3 4 5 6', $x));
66 @ary = split(' ','1 2 3 4 5 6', $x);
67 $cnt = split(' ','1 2 3 4 5 6', $x);
71 $_ = join(':', split(//, '123', -1));
73 $_ = join(':', split(//, '123', 0));
75 $_ = join(':', split(//, '123', 2));
77 $_ = join(':', split(//, '123', 6));
80 @ary = split(//, '123', $_);
81 $cnt = split(//, '123', $_);
86 $_ = join(':', split(/:/,'1:2:3:4:5:6:::', 999));
88 @ary = split(/:/,'1:2:3:4:5:6:::', 999);
89 $cnt = split(/:/,'1:2:3:4:5:6:::', 999);
94 $_ = join(':', split);
95 is($_ , '1:2:3:4', "Split and join without specifying a split pattern");
97 # Does assignment to a list imply split to one more field than that?
98 $foo = runperl( switches => ['-Dt'], stderr => 1, prog => '($a,$b)=split;' );
101 # Can we say how many fields to split to when assigning to a list?
102 ($a,$b) = split(' ','1 2 3 4 5 6', 2);
104 is($_, '1:2 3 4 5 6', "Storing split output into list of scalars");
107 $_ = join '|', split(/,|(-)/, "1-10,20,,,");
109 @ary = split(/,|(-)/, "1-10,20,,,");
110 $cnt = split(/,|(-)/, "1-10,20,,,");
114 $_ = join '|', split(/,|(-)/, "1-10,20,,,", 10);
116 @ary = split(/,|(-)/, "1-10,20,,,", 10);
117 $cnt = split(/,|(-)/, "1-10,20,,,", 10);
131 $_ = join('|', split(/x/, '',-1), 'Z');
133 @ary = split(/x/, '',-1);
134 $cnt = split(/x/, '',-1);
137 $_ = join('|', split(/x/, '', 1), 'Z');
139 @ary = split(/x/, '', 1);
140 $cnt = split(/x/, '', 1);
143 $_ = join('|', split(/(p+)/,'',-1), 'Z');
145 @ary = split(/(p+)/,'',-1);
146 $cnt = split(/(p+)/,'',-1);
149 $_ = join('|', split(/.?/, '',-1), 'Z');
151 @ary = split(/.?/, '',-1);
152 $cnt = split(/.?/, '',-1);
157 $_ = join '|', split(/^a/m, "a b a\na d a", 20);
159 @ary = split(/^a/m, "a b a\na d a", 20);
160 $cnt = split(/^a/m, "a b a\na d a", 20);
164 $_ = join '|', split(/a$/m, "a b a\na d a", 20);
166 @ary = split(/a$/m, "a b a\na d a", 20);
167 $cnt = split(/a$/m, "a b a\na d a", 20);
171 $_ = join '|', split(/^aa/m, "aa b aa\naa d aa", 20);
173 @ary = split(/^aa/m, "aa b aa\naa d aa", 20);
174 $cnt = split(/^aa/m, "aa b aa\naa d aa", 20);
178 $_ = join '|', split(/aa$/m, "aa b aa\naa d aa", 20);
180 @ary = split(/aa$/m, "aa b aa\naa d aa", 20);
181 $cnt = split(/aa$/m, "aa b aa\naa d aa", 20);
186 @ary = split(/\s*:\s*/);
187 $cnt = split(/\s*:\s*/);
192 is('p:q:r:s', join ':', split('abc' =~ /b/, 'p1q1r1s'));
193 @ary = split('abc' =~ /b/, 'p1q1r1s');
194 $cnt = split('abc' =~ /b/, 'p1q1r1s');
198 $_ = join ':', split /^/, "ab\ncd\nef\n";
199 is($_, "ab\n:cd\n:ef\n","check that split /^/ is treated as split /^/m");
201 $_ = join ':', split /\A/, "ab\ncd\nef\n";
202 is($_, "ab\ncd\nef\n","check that split /\A/ is NOT treated as split /^/m");
204 # see if @a = @b = split(...) optimization works
205 @list1 = @list2 = split ('p',"a p b c p");
212 $_ = join ':', split /(?=\w)/, "rm b";
214 @ary = split /(?=\w)/, "rm b";
215 $cnt = split /(?=\w)/, "rm b";
220 @ary = map {ord} split //, v1.20.300.4000.50000.4000.300.20.1;
221 $cnt = split //, v1.20.300.4000.50000.4000.300.20.1;
225 @ary = split(/\x{FE}/, "\x{FF}\x{FE}\x{FD}"); # bug id 20010105.016 (#5088)
226 $cnt = split(/\x{FE}/, "\x{FF}\x{FE}\x{FD}"); # bug id 20010105.016 (#5088)
232 @ary = split(/(\x{FE}\xFE)/, "\xFF\x{FF}\xFE\x{FE}\xFD\x{FD}"); # variant of 31
233 $cnt = split(/(\x{FE}\xFE)/, "\xFF\x{FF}\xFE\x{FE}\xFD\x{FD}"); # variant of 31
247 my @a = map ord, split(//, join("", map chr, (1234, 123, 2345)));
248 my $c = split(//, join("", map chr, (1234, 123, 2345)));
255 my @a = map ord, split(/$x/, join("", map chr, (1234, ord($x), 2345)));
256 my $c = split(/$x/, join("", map chr, (1234, ord($x), 2345)));
269 my @charlist = split //, $sushi;
270 my $charnum = split //, $sushi;
286 my ($a, $b, $c) = split(/\x40/, $s);
290 my ($a, $b) = split(/\x{100}/, $s);
293 my ($a, $b) = split(/\x{80}\x{100}\x{80}/, $s);
297 my ($a, $b) = split(/\x40\x{80}/, $s);
301 my ($a, $b, $c) = split(/[\x40\x{80}]+/, $s);
310 my @b = split( //, $a );
311 my $c = split( //, $a );
323 my @a = split(/\xFE/, "\xFF\xFE\xFD");
324 my $b = split(/\xFE/, "\xFF\xFE\xFD");
335 $r = join ':' => split($pat, "hello cruel world");
342 # split /(A)|B/, "1B2" should return (1, undef, 2)
343 my @x = split /(A)|B/, "1B2";
344 my $y = split /(A)|B/, "1B2";
354 my @a = split /\r?\n/, "$char\n";
355 my $b = split /\r?\n/, "$char\n";
367 my @d = split /[,]/,$1;
368 my $e = split /[,]/,$1;
378 eval { @a=split(/[, ]+/,$p) };
379 eval { $b=split(/[, ]+/,$p) };
381 is ("$@-@a-", '-a b-', '#20912 - split() to array with /[]+/ and utf8');
390 @split = split /$pattern/, $str;
391 push @res, scalar(@split);
395 is($res[2], 2, '#123469 - split with utf8 pattern after handling non-utf8 EXPR');
402 $n = @a = split /,/,$p;
408 # assigning off the end of the array after a split could leave garbage
412 @a = split /,/, ',,,,,';
420 my @s = split(" \0 ", $src);
421 my @r = split(/ \0 /, $src);
422 my $cs = split(" \0 ", $src);
423 my $cr = split(/ \0 /, $src);
435 () = split m/,/, "", BANG;
442 scalar(our @PATH = split /::/, "Font::GlyphNames");
452 @results= split(0||" ", $expr);
453 is @results, 2, 'split(0||" ") is treated like split(" ")'; #'
456 @results= split $cond ? " " : qr/ /, $expr;
457 is @results, 3, 'split($cond ? " " : qr/ /, $expr) works as expected (like qr/ /)';
459 @results= split $cond ? " " : qr/ /, $expr;
460 is @results, 2, 'split($cond ? " " : qr/ /, $expr) works as expected (like " ")';
463 @results = split /\s/, $expr;
465 "split on regex of single space metacharacter: captured 4 elements";
467 "split on regex of single space metacharacter: first element is empty string";
469 @results = split / /, $expr;
471 "split on regex of single whitespace: captured 4 elements";
473 "split on regex of single whitespace: first element is empty string";
475 @results = split " ", $expr;
477 "split on string of single whitespace: captured 3 elements";
479 "split on string of single whitespace: first element is non-empty";
482 @results = split " ", $expr;
484 "split on string of single whitespace: captured 3 elements";
486 "split on string of single whitespace: first element is non-empty; multiple contiguous space characters";
491 @results = split $cond ? qr/ / : " ", $expr;
495 qq{split(\$cond ? qr/ / : " ", "$exp") behaves as expected over repeated similar patterns};
499 # RT #130907: unicode_strings feature doesn't work with split ' '
509 my @got = split " ", $str;
510 is @got, 2, "whitespace split: $desc: field count";
511 is $got[0], '.', "whitespace split: $desc: field 0";
512 is $got[1], '/', "whitespace split: $desc: field 1";
517 # 'RT #116086: split "\x20" does not work as documented';
521 @results = split uni_to_native("\x20"), $expr;
523 "RT #116086: split on string of single hex-20: captured 3 elements";
525 "RT #116086: split on string of single hex-20: first element is non-empty";
528 @results = split uni_to_native("\x20"), $expr;
530 "RT #116086: split on string of single hex-20: captured 3 elements";
532 "RT #116086: split on string of single hex-20: first element is non-empty; multiple contiguous space characters";
535 # Nasty interaction between split and use constant
537 ($a,$b,$c) = split //, $foo, nought;
538 is nought, 0, 'split does not mangle 0 constants';
543 @aaa = split //, $bbb[1];
545 'split-to-array does not free its own argument';
547 () = @a = split //, "abc";
548 is "@a", "a b c", '() = split-to-array';
550 (@a = split //, "abc") = 1..10;
551 is "@a", '1 2 3', 'assignment to split-to-array (pmtarget/package array)';
554 (@a = split //, "abc") = 1..10;
555 is "@a", '1 2 3', 'assignment to split-to-array (targ/lexical)';
557 (@{\@a} = split //, "abc") = 1..10;
558 is "@a", '1 2 3', 'assignment to split-to-array (stacked)';
564 @a = split /-(?{ $c++ })/, "a-b-c";
570 @a = split /$sep(?{ $c++ })/, "a-b-c";
575 # check that my/local @array = split works
582 local @a = split /:/, $s;
583 is "@a", "a b c", "local split inside";
585 is "@a", "x y z", "local split outside";
589 my @b = split /:/, $s;
590 is "@b", "a b c", "my split inside";
592 is "@b", "x y z", "my split outside";
595 # check that the (@a = split) optimisation works in scalar/list context
604 $outer = (@lex = split /:/, $s);
605 is "@lex", "a b c d e", "array split: scalar cx lex: inner";
606 is $outer, 5, "array split: scalar cx lex: outer";
608 @outer = (@lex = split /:/, $s);
609 is "@lex", "a b c d e", "array split: list cx lex: inner";
610 is "@outer", "a b c d e", "array split: list cx lex: outer";
612 $outer = (@pkg = split /:/, $s);
613 is "@pkg", "a b c d e", "array split: scalar cx pkg inner";
614 is $outer, 5, "array split: scalar cx pkg outer";
616 @outer = (@pkg = split /:/, $s);
617 is "@pkg", "a b c d e", "array split: list cx pkg inner";
618 is "@outer", "a b c d e", "array split: list cx pkg outer";
620 $outer = (my @a1 = split /:/, $s);
621 is "@a1", "a b c d e", "array split: scalar cx my lex: inner";
622 is $outer, 5, "array split: scalar cx my lex: outer";
624 @outer = (my @a2 = split /:/, $s);
625 is "@a2", "a b c d e", "array split: list cx my lex: inner";
626 is "@outer", "a b c d e", "array split: list cx my lex: outer";
628 $outer = (local @pkg = split /:/, $s);
629 is "@pkg", "a b c d e", "array split: scalar cx local pkg inner";
630 is $outer, 5, "array split: scalar cx local pkg outer";
632 @outer = (local @pkg = split /:/, $s);
633 is "@pkg", "a b c d e", "array split: list cx local pkg inner";
634 is "@outer", "a b c d e", "array split: list cx local pkg outer";
636 $outer = (@{\@lex} = split /:/, $s);
637 is "@lex", "a b c d e", "array split: scalar cx lexref inner";
638 is $outer, 5, "array split: scalar cx lexref outer";
640 @outer = (@{\@pkg} = split /:/, $s);
641 is "@pkg", "a b c d e", "array split: list cx pkgref inner";
642 is "@outer", "a b c d e", "array split: list cx pkgref outer";
652 @a = split(/-/,"-");
654 ok eval { $a[0] = 'a'; 1; }, "array split filling AvARRAY: assign 0";
655 is "@a", "a b", "array split filling AvARRAY: result";
662 my @a = split ' ', $s;
669 my @a = foo(1, scalar split " ", "a b");
670 is(join('', @a), "12", "Scalar split to a sub parameter");
675 my @a = foo(1, scalar(@x = split " ", "a b"));
679 fresh_perl_is(<<'CODE', '', {}, "scalar split stack overflow");
680 map{int"";split//.0>60for"0000000000000000"}split// for"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
683 # RT #132334: /o modifier no longer has side effects on split
693 is($separator,$effective,"Going to split '$text' with '$separator'");
694 my @result = split($separator,$text);
699 # check that the (@ary = split) optimisation survives @ary being modified
701 fresh_perl_is('my @ary; @ary = split(/\w(?{ @ary[1000] = 1 })/, "abc");',
702 '',{},'(@ary = split ...) survives @ary being Renew()ed');
703 fresh_perl_is('my @ary; @ary = split(/\w(?{ undef @ary })/, "abc");',
704 '',{},'(@ary = split ...) survives an (undef @ary)');
706 # check the (@ary = split) optimisation survives stack-not-refcounted bugs
707 fresh_perl_is('our @ary; @ary = split(/\w(?{ *ary = 0 })/, "abc");',
708 '',{},'(@ary = split ...) survives @ary destruction via typeglob');
709 fresh_perl_is('my $ary = []; @$ary = split(/\w(?{ $ary = [] })/, "abc");',
710 '',{},'(@ary = split ...) survives @ary destruction via reassignment');
721 my $prog = "split $pattern";
729 # gh18032: check that `split " "` does not get converted to `split ""`
731 my @skipwhite= ('split " "', 'split "\x20"', 'split "\N{SPACE}"',
732 'split "$e$sp$e"', 'split');
734 'split / /', 'split m/ /', 'split qr/ /',
735 'split /$e$sp$e/', 'split m/$e$sp$e/', 'split qr/$e$sp$e/'