diff --git a/pp.c b/pp.c index d29356a2efb9..72d0369b2b08 100644 --- a/pp.c +++ b/pp.c @@ -6877,6 +6877,8 @@ PP_wrapped(pp_split, else trailing_empty = 0; } else { + if (m < s) + m = s; dstr = newSVpvn_flags(s, m-s, flags); XPUSHs(dstr); } diff --git a/t/op/split.t b/t/op/split.t index 9a967adb1929..a7c1f958d68f 100644 --- a/t/op/split.t +++ b/t/op/split.t @@ -7,7 +7,7 @@ BEGIN { require './charset_tools.pl'; } -plan tests => 197; +plan tests => 198; $FS = ':'; @@ -725,3 +725,4 @@ SKIP: { }, "special-case pattern for $prog"); } } +fresh_perl_is('split /00|0\G/, "000"', '', {}, "split with \\G doesn't panic");