Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Perl bug? - tr///c Message-ID: <11597@jpl-devvax.JPL.NASA.GOV> Date: 26 Feb 91 20:03:24 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Distribution: comp Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 24 In article evan@mullauna.cs.mu.OZ.AU writes: : The following code: : $foo = '*foo'; : $foo =~ tr/a-zA-Z//c; : print "$foo\n"; : does not produce the output (I) expected. Changing the * to (say) . : produces a different (but similar) result. You need to tell it what you want to translate non-alphabetic characters to. In the absence of a RHS, it'll simply reuse the LHS (unless you supply a d, in which case it will delete the specified characters). So you've essentially said $foo =~ tr/a-zA-Z/a-zA-Z/c; Now, that said, I should say that there's a bug up through 4.0 beta that incorrectly replicates the last character of the RHS when complementing, which is why $foo =~ tr/a-zA-Z/_/c; doesn't work right. It's fixed in real 4.0 though. Larry