in reply to Re^2: Chunking very large files
in thread Chunking very large files

Should be as simple as:

my $sizeRead = $chunkSize; while ($sizeRead == $chunkSize) { $sizeRead = read $in_fh, $buffer, $size; die "Error reading: $!\n" unless defined $sizeRead; ... }

Replies are listed 'Best First'.
Re^4: Chunking very large files
by hiptoss (Novice) on Nov 09, 2011 at 20:13 UTC
    What about the end of the file where $sizeRead will be smaller than chunkSize?

      In that case, $sizeRead will be smaller than $size. Possibly zero if your file is exactly a multiple of the chunk size. You then write the chunk as normal (unless its size zero), and the while loop exits.