<?xml version="1.0" encoding="windows-1252"?>
<node id="854984" title="Re: Insert lines into specific stanza line" created="2010-08-13 15:17:14" updated="2010-08-13 15:17:14">
<type id="11">
note</type>
<author id="230012">
jonadab</author>
<data>
<field name="doctext">
&lt;p&gt;It took me three or four minutes to figure out what your for loop does, and I still have no idea what it has to do with the stated problem.  I think I would try a different approach altogether...&lt;/p&gt;

&lt;code&gt;
open INPUT, '&lt;',  'inputfile';
open OUTPUT, '&gt;', 'resultsfile';
local $/ = "&lt;/stanza&gt;";
while (&lt;INPUT&gt;) {
   my $stanza = $_;
   if ($stanza =~ /&lt;stanza/) {
     my ($dottedquad) = $stanza
            =~ /&lt;stanza\s*(\d+[.]\d+[.]\d+[.]\d+)\s*&gt;/;

     $stanza .= "   sl3 yet another line\n";
     # Make other changes to $stanza here as desired.

     print OUTPUT $stanza . $/;
  }}
&lt;/code&gt;</field>
<field name="root_node">
854973</field>
<field name="parent_node">
854973</field>
</data>
</node>
