Data::BinaryBuffer - The module to work with binary data effectively
version 0.006
use Data::BinaryBuffer; my $buf = Data::BinaryBuffer->new; $buf->write($some_data); # PSD file for ex my $sig = $buf->read(4); die "This is not PSD file" if $sig ne '8BPS'; my $version = $buf->read_uint16be; # etc...
NOTE: This module is in very alpha state. API may change without any notice until version 0.1.
Perl is good for strings, bug not very nice to binary data. This class exactly for that.
Data::BinaryBuffer is a data structure similar to the queue, but optimized to work with blocks of arbitrary size. You can write data to one end of buffer and read from another. Data can be written or read in various formats.
my $buf = Data::BinaryBuffer->new;
Creates empty buffer object.
my $size = $buf->size;
Returns current amount of bytes stored in buffer.
$buf->write($data);
Write scalar to the buffer.
$buf->write_uint8(255); $buf->write_int32be($value);
Write one integer to the buffer.
my $data = $read($size);
Read $size bytes to Perl scalar.
my $num1 = $buf->read_uint32be;
Read integer from buffer.
my $buf2 = $buf->read_buffer($size);
Same as read, but return another buffer. This method is very fast for big data.
read
pack/unpack functions in perldoc
File::Binary
Parse::Binary
Convert::Binary::C
Please report any bugs or feature requests through the issue tracker at https://github.com/vovkasm/data-binarybuffer/issues. You will be notified automatically of any progress on your issue.
This is open source software. The code repository is available for public review and contribution under the terms of the license.
https://github.com/vovkasm/data-binarybuffer
git clone https://github.com/vovkasm/data-binarybuffer.git
Vladimir Timofeev <vovkasm@gmail.com>
This software is copyright (c) 2019 by Vladimir Timofeev.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Data::BinaryBuffer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::BinaryBuffer
CPAN shell
perl -MCPAN -e shell install Data::BinaryBuffer
For more information on module installation, please visit the detailed CPAN module installation guide.