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.
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
The local code is just named Binary.pm, needs renaming, docs checking and CPANing!