This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #7911] no warning for useless /d in tr/0-9//d
[perl5.git] / op.c
diff --git a/op.c b/op.c
index 11e940b..10c1fc9 100644 (file)
--- a/op.c
+++ b/op.c
@@ -3451,6 +3451,15 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
            }
        }
     }
+
+    if(ckWARN(WARN_MISC)) {
+        if(del && rlen == tlen) {
+            Perl_warner(aTHX_ packWARN(WARN_MISC), "Useless use of /d modifier in transliteration operator"); 
+        } else if(rlen > tlen) {
+            Perl_warner(aTHX_ packWARN(WARN_MISC), "Replacement list is longer than search list");
+        } 
+    }
+
     if (grows)
        o->op_private |= OPpTRANS_GROWS;
 #ifdef PERL_MAD
@@ -5802,7 +5811,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
        pp_entereval that it should not throw away any saved lines at scope
        exit.  */
        
-    PL_breakable_sub_generation++;
+    PL_breakable_sub_gen++;
     if (CvLVALUE(cv)) {
        CvROOT(cv) = newUNOP(OP_LEAVESUBLV, 0,
                             mod(scalarseq(block), OP_LEAVESUBLV));