Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Generic front end with back-end drivers?

by pc88mxer (Vicar)
on Feb 12, 2008 at 19:06 UTC ( [id://667653] : note . print w/replies, xml ) Need Help??


in reply to Generic front end with back-end drivers?

This sounds like a classic many-to-many situation, and so it seems that it would be helpful for you to develop an intermediate representation for the data in your files. That is, instead of going from a file directly to DBD, write modules which convert or adapt the file data to a common intermediate form. Then write another module which will store the results via DBD. That would make it easier if later you want to add additional output formats, like HTML or XML or JSON, or if you just want to process it differently.

One idea for the intermediate representation is just an array of hashes. This assumes that your text files contain a list of "records" which each record having "fields". Just write one converter for each file format that normalizes the data to this canonical structure.

Also, are you thinking of treating each file as a DBD database that would be accessed through the DBI API? That's the only time you'd need to create a new DBD driver, and I'm not sure that's really what you want to do.

  • Comment on Re: Generic front end with back-end drivers?