http://www.perlmonks.org?node_id=1030493


in reply to DB Connection using CGI::Application

If you are trying to pass a database connection-handle as a param(), then I would say .. “fuhgeddaboudit!.”   You’re barking up the wrong tree .. the intended solution is actually much simpler(!) than you are making it out to be.

Pause for a moment and consider how CGIApp actually works.   (See also http://cgi-app.org/index.cgi?OrderOfOperations.)

Your CGI application comes into existence to handle one request ... then, it dies.   The sequence of operations, during the lifetime of that one-and-only request, includes the following method calls:

  1. cgiapp_init()
  2. setup()
  3. your request handler, such as 'one' or 'two'
Therefore ... the object exists for the entire time!

Each of these methods occur within a single object, so you actually are free to instantiate any necessary database connection-handles at any point that suits you.   The only thing to bear in mind, from a program-design point of view, is that each of these are method calls, to a single (albeit short-lived...) object, which occur in a definite sequence.

Literally...

I cordially suggest that you should now spend a bit of time at http://www.cgi-app.org.   Read it “entirely, thoughtfully, and carefully.”   Trust me ... the proverbial “little light” will come on.   :-)

Replies are listed 'Best First'.
Re^2: DB Connection using CGI::Application
by Anonymous Monk on Apr 24, 2013 at 19:34 UTC
    I will do that, can I get back to you?
Re^2: DB Connection using CGI::Application
by Anonymous Monk on Apr 25, 2013 at 03:43 UTC

    If you are trying to pass a database connection-handle as a param(), then I would say .. “fuhgeddaboudit!.”

    Typical sundialsvc4 , didn't read the material he advocates reading