marctwo has asked for the wisdom of the Perl Monks concerning the following question:
I am creating a new file and then using print in a loop to write lines of text to a file. However, I am also then checking to see if any lines have previously been written to that file using -s. This test always says that the file is zero size even if I have just used print to write a line into it. When I check the file it is indeed empty until the script has finished when there are multiple lines in the file.
What I want to know is, does print only write to the file once the filehandle is closed? How can I write data into a file and (before closing it) test to see if data has already been written?
Many thanks for your help,
Marc
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Does print() write immediately to a file?
by Abigail-II (Bishop) on Oct 15, 2003 at 12:41 UTC | |
|
Re: Does print() write immediately to a file?
by robartes (Priest) on Oct 15, 2003 at 11:36 UTC | |
by marctwo (Acolyte) on Oct 15, 2003 at 13:11 UTC | |
|
Re: Does print() write immediately to a file?
by ctilmes (Vicar) on Oct 15, 2003 at 11:36 UTC |