Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I've actually implemented a backend for this, and am now looking to rewrite the frontend. What I'm using now to specify the format is a large data structure. I've been looking around for an existing mini-language to adapt, but have yet to find one.

    My code is here []. The binary file parser is File::ComplexFormat [] (after I rewrite with a new mini-language I intend to rename it to Parse::Binary, or something, and release to CPAN); the parser for the data structure is File::ComplexFormat::SpecParser::Array []. The only working example of the module is File::Format::Diablo::d2s [], for parsing Diablo 2 character files. The file format is described in the call to File::ComplexFormat, as the spec argument.

    My problem hasn't been so much in specifying the data types; I could probably use something similar to C, or just the single lines I have in the data structure format I have now. The problems arise when parsing a complex file; some fields are there only if other fields are set to some value, and there are arrays of values, sometimes based on some count, sometimes based on a delimiter. This requires conditionals and loops based on values that have already been read. In addition, I'm creating a data structure from the parsed file (or writing a data structure to the parsed file), so I needed code that allows me to name the keys in the hash and group like values into sub-hashes.

    If you have any ideas on the mini-language or the code I have already I'd like to hear them.