From: snacktime Date: 2006-08-13T12:19:42+09:00 Subject: Re: perl tr and ruby String#tr > Have you tried the seemingly simple approach like this, which avoids > eval: > > ratdog:~ mike$ irb --prompt simple > >> @upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' > => "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > >> def uc(s) > >> s.tr('abcdefghijklmnopqrstuvwxyz', @upper_case) > >> end > => nil > >> uc('banana') > => "BANANA" > >> @upper_case = 'abcdefghijklmnopqrstuvwxyz' > => "abcdefghijklmnopqrstuvwxyz" > >> uc('banana') > => "banana" Yes I tried it without eval also, but it won't produce the same output as the perl code. I've tried every incantation I can think of but no luck. I'm checking my results by comparing them to the output of perl's String::Parity. The perl code I posted is basically an abbreviation of what String::Parity does when setting even parity. It's the last bit in this damn module I'm working on also:) If I get this figured out I'll be done.