http://www.perlmonks.org?node_id=533442


in reply to Fast parsing for cypher block chaining

Why not let Perl do the buffering for you. read and write are buffered (unlike sysread and syswrite).
while (my $bufsize = read(INFILE, my $eight_byte_chunk, 8)) { ...[ Add padding ]... ...[ Encrypt ]... ...[ Merge with IV ]... ...[ Compute new IV ]... write(OUTFILE, $eight_byte_chunk, 8); }