Jonathan Mast wrote:
>
We have a socket server that, in addition to serving data, also writes
logging statements to a file.

My question concerns the correctness of how it accesses the log file.  The
script is running continuously and all the log file IO stuff is inside the
main 'while' loop.
The file is opened, written to and closed during each iteration of the
loop.  This seems very inefficient to me, all the opening and closings I
presume are IO intensive.
Would placing the opening and closing of the filehandle outside the while
loop be a good idea?

Are you experiencing system problems that may be due to frequent file
openings and closures? If not then perhaps it's better to leave it
alone.

If it would make you feel better then you could try the change you
suggest, but it is unlikely to have any real benefit unless the cycle
time of your loop is substantially under a second. In any case, you must
arrange to flush the output buffer either automatically, as John has
suggested, or explicitly. Take a look at IO::Handle.

HTH,

Rob



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to