in reply to Splitting a binary file

There are various ways to do this:

Just pick one method and stick with it: loop over the big file to read "x" bytes, open a suitable output, write the chunk, and close it. Don't repeat any data across chunks -- that will mess you up later.

Since you're talking about "sending" the chunks, I assume they're relatively small, so one chunk fits in memory. (If the chunks are too big, you'd need a nested loop to read "sub-chunks" that do fit, outputting each one to the "main chunk", then closing that when it's the right size, and moving on to the next main chunk.)

If the chunks are being stored as separate files, putting them back together again is really simple. Either a single shell command:

cat fatset.chunk* > fatset
or in perl:
{ local $/; # sets input_record_separator to "undef" open(O,">fatset"); for my $f (sort <fatset.chunk*>) { open(I,$f); $_ = <I>; # reads entire chunk at once. print O; } close O; }
Just be sure that if you need to make more than 9 chunks, use leading zeros in the file names for chunks 1-9, so that the names will sort naturally into their proper order. Use  sprintf( 'fatset.chunk%03d', $chunknumber++ ) for that.

Naturally, if you use the perl version, add some error checking...