From: Rob Das <[EMAIL PROTECTED]>
> I added the following line to my program:
> $/ = \65536; 

It'd be better to use
        read FILE, $buffer, 65536;
and leave $/ alone. Keep in mind that $/ is global and affects all 
filehandles you try to read from using the diamond operator (<FILE>).

So if possible you should leave $/ and similar variables intact and 
if you really have to change them you should local()ize the change to 
the smallest possible block.
 
> This was because I'm running out of memory when slurping entire files
> into memory (potentially hundreds of meg). 

Then don't do that :-)
Read and the process the files in chunks.

> However, the (separate) log
> file I'm writing afterwards is not getting created - nor am I getting
> any error messages. If I comment this line out, it works fine. I tried
> the following: $opfh = select(OUTFILE); $| = 1; select ($opfh); 
> 
> ... to try and flush the buffer, but to no avail.
> 
> Would someone tell me what I need to do to get this file written out
> please?

I don't know how could changing $/ prevent a file from being written.
Except maybe is you try to read a line from the terminal after you 
change the $/ with
        $response = <STDIN>;

In that case I'd expect this command to only return after the poor 
user types those 64KB of stuff.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to