Well since you are getting at least some of the IN lines into the OUT file, the opens must have worked. The code looks like it should be fine.

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.

while (<IN>) { chomp; #or s/\s*$//; print OUT "$_\n"; #this "resets" line ending to your OS's version }
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.

In reply to Re: Append incomplete by Marshall
in thread Append incomplete by Ramyaa.Venkat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.