Just be a bit more generous and grant your script one more backslash:
$a = 'ABCD'; $b = 'bcda'; $z = 'DCBA'; eval "\$z =~ tr/$a/$b/"; print $z, "\n"; # prints: adcb ## ... because eval "$z" is the constant 'DBCA' ## rather than the variable $z !!! Regards, Detlef Louis Pouzin wrote: > Hi, > > I haven't found the way to make the following snippet work. > > $a = 'ABCD'; $b = 'bcda'; $z = 'DCBA'; > eval "$z =~ tr/$a/$b/"; > print $z, "\n"; # should be adcb > __END__ > DCBA > > OTOH the following works: > > $a = 'ABCD'; $b = 'bcda'; $_ = 'DCBA'; > eval "tr/$a/$b/"; > print $_, "\n"; # should be adcb > __END__ > adcb