diff options
-rw-r--r-- | op.c | 4 | ||||
-rw-r--r-- | pod/perldelta.pod | 6 | ||||
-rw-r--r-- | pod/perldiag.pod | 6 | ||||
-rw-r--r-- | t/lib/warnings/op | 11 |
4 files changed, 26 insertions, 1 deletions
@@ -6658,6 +6658,10 @@ Perl_ck_split(pTHX_ OP *o) kid->op_type = OP_PUSHRE; kid->op_ppaddr = PL_ppaddr[OP_PUSHRE]; scalar(kid); + if (ckWARN(WARN_REGEXP) && ((PMOP *)kid)->op_pmflags & PMf_GLOBAL) { + Perl_warner(aTHX_ packWARN(WARN_REGEXP), + "Use of /g modifier is meaningless in split"); + } if (!kid->op_sibling) append_elem(OP_SPLIT, o, newDEFSVOP()); diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 27823a7ec0..f5d98ef388 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -559,8 +559,12 @@ The command-line options -s and -F are now recognized on the shebang Use of the C</c> match modifier without an accompanying C</g> modifier elicits a new warning: C<Use of /c modifier is meaningless without /g>. + Use of C</c> in substitutions, even with C</g>, elicits -C<Use of /c modifier is meaningless in s///>. +C<Use of /c modifier is meaningless in s///>. + +Use of C</g> with C<split> elicits <Use of /g modifier is meaningless +in split>. =back diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 35f26c4793..08f342aee1 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -3996,6 +3996,12 @@ modifier is not presently meaningful in substitutions. use the /g modifier. Currently, /c is meaningful only when /g is used. (This may change in the future.) +=item Use of /g modifier is meaningless in split + +(W regexp) You used the /g modifier on the pattern for a C<split> +operator. Since C<split> always tries to match the pattern +repeatedly, the C</g> has no effect. + =item Use of *glob{FILEHANDLE} is deprecated (D deprecated) You are now encouraged to use the shorter *glob{IO} form diff --git a/t/lib/warnings/op b/t/lib/warnings/op index ff00dcd2ed..7833562273 100644 --- a/t/lib/warnings/op +++ b/t/lib/warnings/op @@ -111,6 +111,8 @@ Package `%s' not found (did you use the incorrect case?) + Use of /g modifier is meaningless in split + Mandatory Warnings ------------------ Prototype mismatch: [cv_ckproto] @@ -952,3 +954,12 @@ EXPECT Use of "package" with no arguments is deprecated at - line 3. Global symbol "BEGIN" requires explicit package name at - line 4. BEGIN not safe after errors--compilation aborted at - line 4. +######## +# op.c +# 20020401 mjd@plover.com at suggestion of jfriedl@yahoo.com +use warnings 'regexp'; +split /blah/g, "blah"; +no warnings 'regexp'; +split /blah/g, "blah"; +EXPECT +Use of /g modifier is meaningless in split at - line 4. |