Dear Stew,
It really sounds like you have been hitting your head against some really basic and well-known mod_perl things. So the last post about RTFM is an extremely good idea. Mod_perl requires a bit of reading when you start and then some experimentation until you get used to it.
Regarding your questions:
- mod_perl embeds a single persistent perl interpreter instance in apache as opposed to launching a new one each time a page is opened. So you typically use a parent program (launched once when the server is soft-restarted) and a child program (called from a browser, but also sharing the memory of the parent).
- This means if you use global variables they will clobber you right on the head, being shared across all calls to one or all of the apache server child processes. one of the very first programming examples (a counter) in the docs does what you are talking about. (hint: use lexicals)
- Likewise with database connections, if you happen to open a db connection in your child code it will stay open. probably would work if you undef'd it but you can also open a connection in the parent, there is in fact a connection pool module for this purpose. read about it.
- In general the really extremely good advice is to use strict. mod_perl *will* have your brain for breakfast if you do not use strict. 'nuf said.
- If you are porting from CGI there is also good documentation in the same place on porting from cgi.
Good luck. Mod_perl is definitely worth it, but you have not yet invested the time and effort required to get you into it, since you would already be using strict if you had even opened the cover of the book. Just the first part of the free documentation might be enough but then you will want to read more, hopefully. I recommend if you don't like reading, to stop using mod_perl since you get out of it exactly what you put into it. Of course you can run like CGI in this environment, see the docs.
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.