in reply to How to reconstruct a SQL query from an executed $sth
Sounds to me like what you are building is brute force (lots of wheel re-invention) and might benefit from a different approach. I can't help but cringe at the thought of subroutines that print output instead of returning output - maybe if you seperated your content from your format you wouldn't have this problem.
Just as a thought, i might approach this by writing a sub or two that accepts some parameters, grabs the data from the database and returns a data structure containing that data. Then, that data structure could be passed to a variety of subs that handle how it should be displayed. XML is very good for this kind of problem - you can transform it to HTML for the website (check out XML::LibXML and XML::LibXSLT) and to a PDF file for the printer (check out XML::Handler::AxPoint). You might even be able to use the powerful mod_perl 'plugin' AxKit to drive your app.
Update:
Consider this site. This particular node is #221372. If
i want to access this node, i can pass the number off to
index.pl like so:
http://www.perlmonks.org/index.pl?node_id=221372
Behind the scenes at Perlmonks, a SQL query is executed and the contents of this node are munged into themed HTML. If i want an XML version of this node, i simply pass another parameter to index.pl like so:http://www.perlmonks.org/index.pl?node_id=221372&displaytype=xml
Again, a SQL query is executed, but this time the contents are rendered into XML. My point of all this is that for both requests, only the node id and display type were needed. No SQL was reconstructed. I don't see why your app has to reconstruct SQL to serve different displays of the same data.jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|