Created
September 17, 2013 15:05
-
-
Save dotandimet/6595595 to your computer and use it in GitHub Desktop.
Tie::LevelDB and binary files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use File::Slurp; | |
use Tie::LevelDB; | |
my $file_name = shift; # give the script an image file argument - preferably a PNG. | |
my $db = new Tie::LevelDB::DB("db/"); | |
my $buffer; | |
read_file( $file_name, binmode => ':raw', buf_ref => \$buffer ); | |
write_file( 'bin_out.png', {binmode => ':raw'}, $buffer ); | |
$db->Put($file_name, $buffer); | |
my $out_buffer = $db->Get($file_name); | |
write_file( 'bin_out2.png', {binmode => ':raw'}, $out_buffer ); | |
# bin_out2.png is unfortunately much shorter than bin_out.png :-( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment