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


in reply to Re^2: Fast parsing for cypher block chaining
in thread Fast parsing for cypher block chaining

I suspect you will do no worse letting Perl handle the buffering for you:
$/ = \8; # Read 8-byte records. Behind the scenes, Perl will do buffer +ing of reads. $out_buffer .= blowfishify($_) while <INFILE>; print OUTFILE $out_buffer;
Alternatively, you could (with a sufficiently modern Perl) read from your buffer as if it were a filehandle, using the same $/ = \8 trick.
open BUF, '<', \$buffer or die "$!: Could not open buffer\n"; $/ = \8; $out_buffer .= blowfishify($_) while <INFILE>; print OUTFILE $out_buffer;
They're tidier ways of doing what you want, but you'd have to try them to see whether they buy or lose you any efficiency. My guess is that the I/O isn't going to be the bottleneck, anyway; the encryption is.

Caution: Contents may have been coded under pressure.