On 11 Mar 2004, Perrin Harkins wrote:
As Skylos also pointed out, a common approach for handling these things is to have a singleton class. If that sounds too confusingly OO for you, just think of a simple utility function that you always call to get a $dbh:
Wow... Perrin... That seems to have worked a charm! Thanks to yourself and Skylos for your help. I think its time I pulled out the old Perl 5 textbook and moved to the OOP chapter :)
Glad to hear you are back on the right track (Perrin really is good at consisely stating and solving these problems isn't he).
If you want to look at a clean and simple framework for building OO CGI apps, have a look at the CGI::Application module. Don't let the name confuse you, it works equally well under mod_perl (as long as you avoid the standard mod_perl pitfalls).
It will give you a good start, and will most likely save you from some common pitfalls when building OO CGI applications. Depending on how you built your app, it might even be easy to move to this model (if you currently use a separate function for each page). There is also a very helpful mailing list with an active community supporting it.
Cheers,
Cees
-- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html