http://qs321.pair.com?node_id=11122229


in reply to tr operator in eval -- updated

I don't think that answer is correct. I know that tr does not interpolate, the patterns are defined at compile time according to the camel book. But the book says that you can put variables in the tr statement if you then use eval to execute the statement. the example in the book (p.76) is  eval "tr/$oldlist/$newlist/;" This does not work. this two step however does work:
# this next two step works..... $xtr = "$bad =~ tr/$card//;" ; $kards = eval "$xtr;"; print "xtr kards = $kards from eval cmd : $xtr\n"; #output: xtr kards = 5 from eval cmd : AKQJT98765432KKKK =~ tr/K// +;