<?xml version="1.0" encoding="windows-1252"?>
<node id="1006277" title="Re: change all occurances of string1 into string2" created="2012-11-29 10:29:01" updated="2012-11-29 10:29:01">
<type id="11">
note</type>
<author id="832495">
choroba</author>
<data>
<field name="doctext">
Too many curlies. [toolic]'s advice is good, but you can safely remove even more:&lt;c&gt;
s/$thing/$translate{$thing}/g;
&lt;/c&gt;
Be careful, though, if one translation results in a word that another translation might translate again.&lt;br&gt;
Sometimes, avoiding the inner loop by constructing the regex leads to a faster solution:
&lt;c&gt;
my $re = join '|', keys %translate;
$re = qr/($re)/;

while (&lt;&gt;) {
    s/$re/$translate{$1}/g;
    print;
}
&lt;/c&gt;
You might need to add some &lt;c&gt;\b&lt;/c&gt; boundaries to the regex so it does not match in the middle of a word.
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-832495"&gt;

&amp;#1604;&amp;#1405;&amp;#4285;† &amp;#6514;&amp;#6482;&amp;#9898;&amp;#10186;&amp;#4281;&amp;#5651;&amp;#5511; &amp;#5045;&amp;#5651;&amp;#5511;&amp;#9137; &amp;#4281;&amp;#6514;&amp;#119243;&amp;#409;&amp;#5651;&amp;#5511;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1006270</field>
<field name="parent_node">
1006270</field>
</data>
</node>
