in reply to Calling functions

Ok so I've set it so that Perl will flush after every write. I've also added another loop in split_logfile() to close every file (perhaps it wasn't finished writing to the files before it moved on to gen_stats()?). But, this has no effect. I still have several random files that are zero length, as if the log entries are not being written at all. Oddly enough, there are several files that appear to be written correctly. I just don't get it...

Replies are listed 'Best First'.
Re (tilly) 2: Calling functions
by tilly (Archbishop) on Mar 23, 2001 at 07:37 UTC
    What platform are you on?

    On Windows when dealing with shared filesystems I have been burned enough that I routinely make sure that I have waited a substantial time (eg one second) between when I closed a file and when I do anything which depends on my write being visible to the world. Why this should be necessary I do not know, but then again I likewise don't bother to remember the exact combination of versions of Perl and Windows in which renaming a file from FOO to foo will delete the file because it does not realize that the target is the original file. (So delete the existing, then go to ren...oops.)

    I merely know that I was burned and the absolutely safe fixes were to sleep in the one case or in the other to rename into another directory and then rename back. (Contrary to Microsoft's documentation on the bug, renaming through another name in the same directory was not safe.)

    Anyways it is possible that you are hitting bugs...

Re: Re: Calling functions
by brendonc (Novice) on Mar 23, 2001 at 04:40 UTC
    I must have overlooked something. I did some further testing, and it appears that if I don't close the files that I've opened then the data does not get fully written to them. I should have known this... but in the original script from the Apache source it didn't do this - probably because it only had one routine to do and then the script ended, closing all the files automatically.

    Thanks to all for the help!