Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by Rhandom (Curate)
on Dec 10, 2004 at 16:23 UTC ( [id://413895]=note: print w/replies, xml ) Need Help??


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

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)];
  • Comment on Re^4: Performance Trap - Opening/Closing Files Inside a Loop

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://413895]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (8)
As of 2024-04-18 14:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found