Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Comment on

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

Your approach goes wrong on several levels.
First of all, you're not supposed to store database handles as persistent variables. It's a bad, bad idea. Use Apache::DBI and mod_perl for that. If you do not want to use DBI directly, I believe DBIx::Class does persistence as well.
Next, it won't work like you expect it to. Say that user 1 comes and accesses a.cgi. Along comes user 2 and accesses a.cgi as well. User 1 and 2 move on to b.cgi, but then user 1 decides to go back to a.cgi. But what user 1 sees is not their data -- it is that of user 2, if even that. This will not go well, and is dangerous for sensitive data.

Instead, what it sounds like you want is a session with a storage backend. Consider CGI::Session, for example, or Apache::Session(X) for mod_perl.
If you want to make something that will go beyond just simple CGI scripts and want something extensible and robust, consider Catalyst or Mojolicious(::Lite). Feeling adventurous? Try Combust, which powers many perlweb sites, IIRC. I personally prefer Catalyst, but you might like something else.

HTH


Update: Replaced <pre /> with <code />, because that did not look right at all.

~Thomas~
confess( "I offer no guarantees on my code." );

In reply to Re: mod_cgid, CGI::Fast share values between different scripts? by thomas895
in thread mod_cgid, CGI::Fast share values between different scripts? 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: (8)
    As of 2014-09-23 23:33 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (241 votes), past polls