in reply to
change all occurances of string1 into string2
Too many curlies. toolic's advice is good, but you can safely remove even more:
s/$thing/$translate{$thing}/g;
Be careful, though, if one translation results in a word that another translation might translate again.
Sometimes, avoiding the inner loop by constructing the regex leads to a faster solution:
my $re = join '|', keys %translate;
$re = qr/($re)/;
while (<>) {
s/$re/$translate{$1}/g;
print;
}
You might need to add some
\b boundaries to the regex so it does not match in the middle of a word.