<?xml version="1.0" encoding="windows-1252"?>
<node id="1003747" title="Re: Need help to fine tune perl script to make it faster( currently taking more than 30 minutes)" created="2012-11-13 23:34:59" updated="2012-11-13 23:34:59">
<type id="11">
note</type>
<author id="880879">
space_monk</author>
<data>
<field name="doctext">
Others have given you most of the answer, but it also looks as though you're pulling the record number out by some incredibly convoluted process.

What is wrong with something like:

&lt;code&gt;
/Record(\d+):/ &amp;&amp; do {
  $recnum = $1;
  s/$str1/$str2/g;
  s/$str3/$str4/g;
  ..
}
&lt;/code&gt;
This checks for matching lines and pulls the record number out at the same time...

&lt;p&gt;Note that the regex in the above may not be quite right as your original seems to back up 6 characters from the ':', but the regex can be amended to do that too.&lt;/p&gt;


&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-880879"&gt;
A Monk aims to give answers to those who have none, and to learn from those who know more.
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1003734</field>
<field name="parent_node">
1003734</field>
</data>
</node>
