|go ahead... be a heretic|
Binary data structure to moose class.by chrestomanci (Priest)
|on Jan 02, 2013 at 15:14 UTC||Need Help??|
chrestomanci has asked for the
wisdom of the Perl Monks concerning the following question:
Greeting wise brothers.
I am looking a Moose class reprentation of a binary file format. (The binary file is the metadata file format used by Humax Digital satelite TV recevers. Documented here: http://foxsatdisk.wikispaces.com/.hmt+file+format)
Seeing as the Moose BestPractices discorage overiding new(), the approach I am taking is to insert the raw data as a field in the class, and then have a large number of lazy builders to extract fields. My API currenlty looks like this:
Some of the code in the class looks like this
My problem is that there are rather a lot of those lazy builders, and they are all similar and repetitive. Is there a way I can make all the fields share the same lazy builder, perhaps by putting the unpack information as an attribute to the field definition?
Secondly, when complete, I plan to upload the module to CPAN. Have I chosen a good name for it, or should it live in a different name space?