<?xml version="1.0" encoding="windows-1252"?>
<node id="778734" title="Re: parse array to replace specific spaces with pipes" created="2009-07-09 19:41:29" updated="2009-07-09 19:41:29">
<type id="11">
note</type>
<author id="644375">
Polyglot</author>
<data>
<field name="doctext">
&lt;code&gt;
$sth-&gt;execute;
    open (OUTFILE, "&gt; file.txt")
        or die "Cant open dat file : $!";
    while (@row = $sth-&gt;fetchrow_array) {
        $_ =~ s/\s/\|/g;
        $_ =~ s/(.*)/|$1|/;
        print OUTFILE "@row\n";
    }
    
close OUTFILE;
&lt;/code&gt;

Does that fix it?

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-644375"&gt;
&lt;p&gt;Blessings,
&lt;p&gt;&lt;i&gt;~Polyglot~&lt;/i&gt;
&lt;/div&gt;&lt;/div&gt;
UPDATE: Elisheva has given a better answer.  My answer assumes that the data was read from a file, one line at a time.  Her answer recognizes that each of the parts of the line have not been read in together, but rather individually as separate records, such as from a database.  I had thought your difficulty was in not seeing the pipe at the beginning and end of the line, but if indeed you were not seeing any pipes at all, then her answer will give the proper approach.

</field>
<field name="root_node">
778727</field>
<field name="parent_node">
778727</field>
</data>
</node>
