in reply to Serialization Format that can be read back in chunks?
Untested, and I don't remember what the 57 * 60 is all about. :-) Probably something to do with ideal chunk size for base64.
#!/usr/bin/perl use strict; use MIME::Base64 qw( encode_base64 ); #encode open INFILE, '<', $ARGV[0]; binmode INFILE; open OUTFILE, '>', $ARGV[1]; my $buf; while ( read( INFILE, $buf, 60 * 57 ) ) { print OUTFILE encode_base64($buf); } close OUTFILE; close INFILE; ################################################### #decode_base64.pl: #!/usr/bin/perl use strict; use MIME::Base64 qw( decode_base64 ); open INFILE, '<', $ARGV[0]; open OUTFILE, '>', $ARGV[1]; binmode OUTFILE; my $buf; while ( $buf = <INFILE> ) { print OUTFILE decode_base64($buf); } close OUTFILE; close INFILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Serialization Format that can be read back in chunks?
by pKai (Priest) on Mar 29, 2007 at 22:10 UTC |