This question is not Perl-specific, (although the unpack function will most probably figure into my implementation).
I have to deal with files where multipl
Depending what you want to do with this, it might be a good place to actually write a formal grammar, using Parse::RecDescent, for instance. This will allow you to feed the entire file to the parser, and get a datastructure out of it.