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." );
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|