Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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.


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

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

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (3)
    As of 2018-04-26 01:07 GMT
    Find Nodes?
      Voting Booth?