New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$s = ""; $n = @a = split(/,/, $s); results in undef $n #6407
Comments
From wab@agere.comCreated by wab@agere.comThe following code: produces: But I expect n=0. I get the expected result if I change the code from I also get the expected result if I predefine @a as shown below: Perl Info
|
From @ysthOn 31 Mar 2003 15:39:40 -0000, wab@agere.com wrote:
This is triggered by a weird optimization to @global=split... The code to return undef in this case looks pretty intentional, but Patch is to maint. Added eval{} to former last test since that seems Inline Patch--- perl-5.8/t/op/split.t.orig Tue Feb 18 07:57:52 2003
+++ perl-5.8/t/op/split.t Tue Apr 1 16:24:34 2003
@@ -6,7 +6,7 @@
require './test.pl';
}
-plan tests => 50;
+plan tests => 52;
$FS = ':';
@@ -280,6 +280,13 @@
{
$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');
}
--- perl-5.8/pp.c.orig Wed Mar 19 08:52:36 2003
+++ perl-5.8/pp.c Tue Apr 1 14:44:14 2003
@@ -4785,12 +4785,10 @@
if (gimme == G_ARRAY)
RETURN;
}
- if (iters || !pm->op_pmreplroot) {
- GETTARGET;
- PUSHi(iters);
- RETURN;
- }
- RETPUSHUNDEF;
+
+ GETTARGET;
+ PUSHi(iters);
+ RETURN;
}
#ifdef USE_5005THREADS
End of Patch. |
From @rgsYitzchak Scott-Thoennes wrote:
Agreed -- thanks, applied to blead as #19135 (with the necessary
-- |
From @ysthOn Wed, 2 Apr 2003 21:57:05 +0200, rgarciasuarez@free.fr wrote:
Hmm. Looks like the maint split.t needs to catch up with blead...the |
@rgs - Status changed from 'new' to 'resolved' |
Migrated from rt.perl.org#21765 (status was 'resolved')
Searchable as RT21765$
The text was updated successfully, but these errors were encountered: