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 b679835..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