in reply to change all occurances of string1 into string2
Be careful, though, if one translation results in a word that another translation might translate again.s/$thing/$translate{$thing}/g;
You might need to add some \b boundaries to the regex so it does not match in the middle of a word.my $re = join '|', keys %translate; $re = qr/($re)/; while (<>) { s/$re/$translate{$1}/g; print; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: change all occurances of string1 into string2
by tobyink (Canon) on Nov 29, 2012 at 16:10 UTC |