From: Yitzchak Scott-Thoennes Date: Tue, 1 Apr 2003 16:32:46 +0000 (-0800) Subject: Re: [perl #21765] $s = ""; $n = @a = split(/,/, $s); results in undef $n X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7f18b612425de6038ac70eda799f641227e16a64;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #21765] $s = ""; $n = @a = split(/,/, $s); results in undef $n Message-ID: p4raw-id: //depot/perl@19135 --- diff --git a/pp.c b/pp.c index 7985599..1bbe895 100644 --- a/pp.c +++ b/pp.c @@ -4778,12 +4778,10 @@ PP(pp_split) if (gimme == G_ARRAY) RETURN; } - if (iters || !pm->op_pmreplroot) { - GETTARGET; - PUSHi(iters); - RETURN; - } - RETPUSHUNDEF; + + GETTARGET; + PUSHi(iters); + RETURN; } PP(pp_lock) diff --git a/t/op/split.t b/t/op/split.t index 55b2839..17ab1e6 100755 --- a/t/op/split.t +++ b/t/op/split.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 52; +plan tests => 54; $FS = ':'; @@ -279,6 +279,13 @@ ok(@ary == 3 && { $p="a,b"; utf8::upgrade $p; - @a=split(/[, ]+/,$p); + eval { @a=split(/[, ]+/,$p) }; is ("$@-@a-", '-a b-', '#20912 - split() to array with /[]+/ and utf8'); } + +{ + is (\@a, \@{"a"}, '@a must be global for following test'); + $p=""; + $n = @a = split /,/,$p; + is ($n, 0, '#21765 - pmreplroot hack used to return undef for 0 iters'); +}