[DCPM] Creating a module of objects

Neil Williams linux at codehelp.co.uk
Thu Jan 11 03:46:37 PST 2007


On Thu, 11 Jan 2007 00:05:30 +0000
Steve Marvell <steve at devon-it.co.uk> wrote:

> Neil Williams wrote:
>
> > 1. I'm missing an new() function and I'm not sure what should go in one
> > - the objects are created during the parse, new doesn't seem to have
> > anything to do.
>
> Do you actually need an instance of this object or is it just a
> library of functions.

Only one function, really: FooParse. Accepts an XML file to pass to
XML::Simple and returns an array of objects read from the file. I may
want a second function FooWrite later.
> Personally, I'd use array references.

Thanks, it's working now.

> I must admit, I'm still not sure what you are actually doing :)
>
> Steve

I've attached the working module. Basically, I'm trying to make it
trivial to parse a particular (generic) XML format that is used by a
variety of my programs by hiding all the XML stuff and just providing
an array of objects where the object members are exact matches for the
object members in the original C source code and in the XML itself.
Objects belong to pilot-qof, cashutil / gnucash and gpe-expenses and
more will be added later. The snippet in the module pod content does a
simple calculation of the total number of miles claimed from a
pilot-qof XML file. pilot-qof provides the query interface to isolate
the expenses on a variety of criteria (client, date range etc.) and the
script just provides a useful summary output. Subsequent scripts will
collate data from pilot-qof into a gnucash style invoice.

The XML format is prescribed by the XML schema within the QOF backend
code - applications linked against QOF provide their object
definitions, the library creates the XML format for those objects from
the definition and the script parses the XML format to provide an array
where members are described by the same definition.

--


Neil Williams
=============
http://www.data-freedom.org/
http://www.nosoftwarepatents.com/
http://www.linux.codehelp.co.uk/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: QOFQSF.pm
Type: text/x-perl
Size: 11809 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/devoncornwall-pm/attachments/20070111/41d0c2d6/attachment-0002.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/devoncornwall-pm/attachments/20070111/41d0c2d6/attachment-0003.bin 


More information about the Devoncornwall-pm mailing list