in reply to Code stalls...possible memory leak?

open INFILE, "<$infile"; $text=<INFILE>; close INFILE;

Thats one hefty scalar to have to sort through, especially after it is expanded into xml. You are probably eating most of your system memory by doing this. Perhaps it would be faster to put your data into an array instead:

open INFILE, "<$infile"; @text=<INFILE>; close INFILE;

and then print to the output file in your while loop.

Replies are listed 'Best First'.
Re: Re: Code stalls...possible memory leak?
by chromatic (Archbishop) on Aug 22, 2001 at 06:39 UTC
    Arrays use (slightly) more memory than scalars. If you've diagnosed his trouble correctly, the cure is (slightly) worse than the disease. Of course, the extra several bytes per array element (one SV per line, as opposed to one SV total) can start to add up if there are several lines.

    If it's possible to process on a line by line or chunk by chunk basis, with a limited state machine or a stack of some sort, a while read is the better approach. (I suspect that's what you meant.)