Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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...

  • The CGI process starts.   The object is instantiated.
  • The method-calls occur in the stated sequence.
  • The object coughs-up its output .. then the entire process dies.   (Hey.. life is short... sux.)

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.   :-)


In reply to Re: DB Connection using CGI::Application by sundialsvc4
in thread DB Connection using CGI::Application by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (5)
    As of 2014-12-20 11:36 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (95 votes), past polls