Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Performance Trap - Opening/Closing Files Inside a Loop

by Limbic~Region (Chancellor)
on Dec 10, 2004 at 10:38 UTC ( [id://413881]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re^2: Performance Trap - Opening/Closing Files Inside a Loop
in thread Performance Trap - Opening/Closing Files Inside a Loop

tmoertel,
I had thought about this myself after posting. The reason I didn't give it a lot of initial thought is because the Java developer made it clear that I was not welcome in the sandbox. My guess is that some sort of limited buffer would be best since that's still a whole lot of lines to be keeping all in memory.

Cheers - L~R

  • Comment on Re^3: Performance Trap - Opening/Closing Files Inside a Loop

Replies are listed 'Best First'.
Re^4: Performance Trap - Opening/Closing Files Inside a Loop
by Rhandom (Curate) on Dec 10, 2004 at 11:23 UTC
    If that is the case - combine the two methods.
    1. Buffer the strings up to say 10k or more.
    2. Once they hit that size - look for an open, or cache a new filehandle.
    3. Print out the buffered string for the file and clear the buffer.
    4. Finish off by flushing remaining buffers.
    my @a=qw(random brilliant braindead); print $a[rand(@a)];

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://413881]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.