http://www.perlmonks.org?node_id=445977


in reply to How to use a variable in tr///

Use eval. Or use substitution with a hash instead (untested):
my %translit; # map chars in $orig to chars in $replace @translit{split //, $orig} = split //, $replace; $fname =~ s/(.)/defined($translit{$1}) ? $translit{$1} : $1/eg;