From 7f18b612425de6038ac70eda799f641227e16a64 Mon Sep 17 00:00:00 2001 From: Yitzchak Scott-Thoennes Date: Tue, 1 Apr 2003 08:32:46 -0800 Subject: [PATCH] Re: [perl #21765] $s = ""; $n = @a = split(/,/, $s); results in undef $n Message-ID: p4raw-id: //depot/perl@19135 --- pp.c | 10 ++++------ t/op/split.t | 11 +++++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) 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'); +} -- 2.7.4