An error on print() or close() would be extremely rare, although this could happen (every I/O operation should return a 1 upon success - so you can check that). Other very unlikely things are file system full, file too big, network disk error.
These files are open in text mode, as a wild thought, maybe there is some binary (non ASCII) thing in the IN file that is causing a premature EOF? Meaning the while() loop terminates prematurely due to that. Open the IN file in a text editor, delete all the lines starting from one line before the first line that didn't get appended, and type in some new lines. Re-run the program and see what happens. IF that works, then there is something "funky" about the line that it stops at. I don't know what kind of environment you have but my program editor can open a file in binary mode and I can see things that might not be apparent from the text display.
I guess you could add "print "$.\t$_"; to the loop to give line numbers and display on console of the lines being copied. If you try that, set $|=1; to turn off buffering so you can watch it run easily. Anyway, your code looks fine, I'm guessing something is weird about the IN file.
Update: as another weird thought, there could be something wrong about the line endings depending upon how these files were generated and somehow (I don't now how) this messes up what you think you are seeing.
Some likely suspects in the IN file, CTL-D or CTL-Z could cause an "EOF" (or actually "end of useful data") - not quite the same as "real EOF". The file system keeps track of the number of bytes in the file independent of what those characters are. In binmode(), that file system count is what is used. The text processing layers can be different. end of file chars. There are ways to work around this, but first we have to establish that is what the problem is. The code is simple and correct, at the moment, this is my "best guess" of where to look. Something is weird here outside of the code. I suspect that there is something "wrong" with the IN file.while (<IN>) { chomp; #or s/\s*$//; print OUT "$_\n"; #this "resets" line ending to your OS's version }
In reply to Re: Append incomplete
by Marshall
in thread Append incomplete
by Ramyaa.Venkat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |