Other pages

Parse-Binary-Flexible (Work in Progress)

Why

Perl supplies some built-in methods to get data out of files byte by byte (unpack. To not have to keep repeating the same code over and over, a higher-level format-description layer is needed. CPAN has several modules for parsing arbitrary binary files, most of these seem to require you to specify the format and standback, P::B::F is made of callbacks and allows you to capture/alter/extend the format as it goes.

What?

Subclass Parse::Binary::Flexible to create a Perl module that parses a particular binary file format, eg to parse minecraft's region format (NBT) create an NBT.pm and start using parts of P::B::F to eat appropriate amounts of the binary file contents.

Co-incidentally, James did this already: Perl minecraft region parser

Code

  1. Parse::Binary::Flexible on GitHub

TODO

The local code is just named Binary.pm, needs renaming, docs checking and CPANing!