in reply to Unexpected File Results

I don't have your datafiles to replay the problem but the code shows me two potential causes (operating system dependent):
1) you probably want to set binmode on the outputfiles, as to avoid translation of characters
2) the read call always reserves the right to have read less than the number of bytes you requested it to. Therefore check the returned 'actual bytes read' and see if you need to make another call to read the remaining bytes of the record.

Replies are listed 'Best First'.
Re^2: Unexpected File Results
by Grundle (Scribe) on May 30, 2007 at 15:18 UTC
    I can automatically answer statement 2. I threw a print statement in the loop to see the length of each "$dat" buffer, and they came out correctly.

    Suggestions 1 looks very promising. I suspect that this will most likely solve my problem, since the files are in binary.
Re^2: Unexpected File Results
by Grundle (Scribe) on May 30, 2007 at 15:42 UTC
    Yes, binmode was exactly what I needed, thanks!!!

      Make sure to binmode the input file as well, in case it contains cr-lf pairs which reading would convert to just lf.