Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: How do you feel about mod_perl?

by edebill (Scribe)
on Nov 06, 2001 at 00:04 UTC ( [id://123402] : note . print w/replies, xml ) Need Help??


in reply to How do you feel about mod_perl?

mod_perl is it's own platform. It has some backwards compatibility code for CGI's, but it is much more than just a CGI framework. It's architecture and basic assumptions are quite a bit different from CGI's - in fact non-trivial CGI applications tend to break if you run them under mod_perl (lifespans of variables are quite different).

Likewise, mod_perl lets you do a lot of things that you just can't do under CGI. Cached database connections being the first to come to mind.

And if you really want something revolutionary, combine mod_perl with HTML::Embperl. Gets rid of all those nasty print()'s and gives a better separation of logic from presentation.

Replies are listed 'Best First'.
Re: Re: How do you feel about mod_perl?
by alien_life_form (Pilgrim) on Nov 06, 2001 at 21:14 UTC
    Greetings,

    
    ...
    in fact non-trivial CGI applications tend to break if you
    run them under mod_perl (lifespans of variables are quite different).
    ...
    
    
    As the developer of a non-trivial CGI/mod_perl app, I beg to disagree. Aside from a few traps due to the way Apache::Registry namespaces compiled scripts - and which are easily avoided by a sane use of modules - I find that properly coded CGI does live a comfortable life under mod_perl.

    I suspect that your observation (as the one below about CGI being of no use in the real world) stem mostly from the unfortunate fact that so many CGI apps are sorry, crappy pieces of code assembled by not very experienced programmers working from cut & paste and hearsay.


    Cheers,
    alf


    You can't have everything: where would you put it?

      Yes, if you write your CGI with discipline, you can certainly get it to run unchanged under mod_perl. On the other hand, I've made the same observation about the CGI apps I've downloaded. Lots of people leave out the my's, skip the use strict;, and generally do things in a sloppy manner.

      I'm sure I'll eventually download one and have it run under mod_perl without problems. But it's usually easier to just enable mod_cgi rather than debugging someone else's script.

      As for developing from scratch, well, "limiting" myself to apache/mod_perl doesn't seem to be that big a loss.

      YMMV, of course.

      I'd be curious what you mean by "Aside from a few traps due to the way Apache::Registry namespaces compiled scripts". Are you referring to the way it treats modules with the same name found in different places in the directory structure as the same module? Quite a headache when you have 3 developers using the same webserver to work on the same app - 2 want the stable version of a module, 1 wants the version he's hacking on at the moment.

      I've had trouble while debugging with mod_perl not picking up changes to modules without a webserver bounce (or setting MaxRequestsPerChild to 1). A couple of my coworkers actually have a

      * * * * *    /usr/local/apache/bin/apachectl restart

      cron job to work around this on their dev boxes.

      ED