Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: Fast parsing for cypher block chaining

by Roy Johnson (Monsignor)
on Feb 28, 2006 at 18:25 UTC ( #533446=note: print w/ replies, xml ) Need Help??


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.


Comment on Re^3: Fast parsing for cypher block chaining
Select or Download Code
Re^4: Fast parsing for cypher block chaining
by ikegami (Pope) on Feb 28, 2006 at 18:41 UTC
    In the first snippet, you should move the print into the loop to avoid using gigabytes of memory. That seemed to be the point of the OP's buffering.
    $/ = \8; # Read 8-byte records. Behind the scenes, Perl will do buffer +ing of reads. print OUTFILE blowfishify($_) while <INFILE>;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://533446]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2015-07-04 08:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (58 votes), past polls