On Thu, Nov 15, 2001 at 01:24:33PM +0000, sdouglas@arm.com wrote: > [2a] perl could give a warning, e.g. "Useless use of /d in > transliteration (tr///)", for the following: > perl -we 'my $x = "1x32141x98234"; $x =~ tr/x//d' How is that a useless use of /d? > (which then becomes case [1a]) and > > After the /d is known to be useless it could allow > perl -we '"1x32141x98234" =~ tr/x//d' > > [2b] (somewhat harder and probably not as useful) > perl -we 'my $x = "1x32141x98234"; $x =~ tr/a-z/l-za-m/d' > The tr is useful but the /d isn't. That's probably not very hard at all; simply count the number of characters in each class, and if they're the same, the /d is useless. There could also be a warning when the left side includes more characters than the right side. Of course, adding these warnings would probably affect a fair amount of existing code. RonaldThread Previous | Thread Next