<?xml version="1.0" encoding="windows-1252"?>
<node id="205615" title="Re: Re: How can I remove 0 from first line and empty space from the start of the following line and join them" created="2002-10-15 22:34:02" updated="2004-08-21 20:44:47">
<type id="11">
note</type>
<author id="99151">
krusty</author>
<data>
<field name="doctext">
An efficient alternative to: 
&lt;CODE&gt;
while (&lt;DATA&gt;) {
    $_ .= &lt;DATA&gt;;
    s/^0\s*(.*)\n\s+(.*\n)/$1 $2/s;
    print;
}
&lt;/CODE&gt;
is not to even loop at all.  
&lt;CODE&gt;
{  local $/ = undef;
   $_ = &lt;DATA&gt;;
    s/^0\s*(.*)\n\s+(.*\n)/$1 $2/s;
    print;
}
&lt;/CODE&gt;
caveat is that it eats up memory if you have an extremely large file.&lt;BR&gt;&lt;BR&gt;
Cheers,&lt;BR&gt;
Kristina

&lt;EM&gt;Update: See BrowserUK's post immediately below.  /s would allow the "." to match the newline which I don't want to happen here, but /m will treat the single string as multiple lines and /g will let me match more than once before quitting.&lt;/EM&gt;
</field>
<field name="root_node">
205602</field>
<field name="parent_node">
205608</field>
</data>
</node>
