in reply to Is it possible to mimic mod_perl like startup for CGI?

With the standard CGI model, where your web server forks off a process to run an external program, it's possible to do such a thing, but it seems really tricky and fragile. The web server doesn't necessarily know that it'll run a Perl program and the perl binary it launches almost definitely doesn't know that it would have subroutines already in memory somewhere. Even if it did, it would have to do a substantial amount of bookkeeping to bring that code in to the rest of the program.

Perhaps CGI::FastCGI would work more to your liking.

Replies are listed 'Best First'.
Re^2: Is it possible to mimic mod_perl like startup for CGI?
by sauoq (Abbot) on Oct 06, 2005 at 22:43 UTC
    With the standard CGI model, where your web server forks off a process to run an external program, it's possible to do such a thing, but it seems really tricky and fragile.

    It's not really that tricky or fragile so long as the external program knows it's going to run a perl program. That's how CGI::SpeedyCGI (a.k.a PersistentPerl) does it. It has a small binary front-end that looks for the persistent perl process, starts it if it doesn't exist already, and then hands off control to it. All you have to do is change your shebang line to point at that front-end. (And code for its persistent environment.)

    -sauoq
    "My two cents aren't worth a dime.";