I was looking for an easy way to parse a binary file. I know what the file contains (it’s an MPEG2 transport stream) and know the bit-field layout. It’s just a pain to figure the bits out manually in a hex editor.
Google pointed me to 010 Editor which supports binary templates, which is pretty much what I was looking for. However, this tool only runs on Windows and is commercial. Enough reason to look further.
That’s when I came across the Data::ParseBinary perl module, which is a true relief to use. It supports pretty much every thing you need to parse a binary file:
- Signed and unsigned integers
- Big and little endian
- 8, 16, 32 and 64 bit integers
- Bitfields
- Enum-types to specify your own names for values
- If-constructs: Fields are present or not depending on the value of another field
In short, an incredible tool!