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

Learning mod_perl

by CodeJunkie (Monk)
on Jul 11, 2003 at 12:08 UTC ( #273325=perlquestion: print w/replies, xml ) Need Help??

CodeJunkie has asked for the wisdom of the Perl Monks concerning the following question:

This has been something i've been putting off for a while, but I think the time has come for me to take those first brave steps and check out the super fast world of mod_perl.

Can anyone give me any advice where to start? I've tried doing google searches for information about mod perl and have found the main websites like but I really need some help and examples to get me started.

How different is mod_perl programming compared to standard Perl? Can anyone recommend a good book? Something published by O'Reily maybe?

Any advice, comments or thoughts on mod_perl would be greatly appreciated, it seems to have been neglected on this site (unless i'm not looking in the right places...)


Replies are listed 'Best First'.
Re: Learning mod_perl
by davorg (Chancellor) on Jul 11, 2003 at 12:18 UTC
Re: Learning mod_perl
by adrianh (Chancellor) on Jul 11, 2003 at 12:26 UTC

    mod_perl is just Perl running built into the Apache server. It's not a new language, you just need to learn some new APIs. The only major difference is that mod_perl programs persist, rather than being run from scratch every time you run a .pl or a .cgi.

    You really need to be familiar with OO perl and writing modules tho'. So if you don't know that learn that first.

    On the mod_perl front I'd start by giving the mod_perl guide then dig into one of the many books, articles and tutorials and presentations that are available.

      You really need to be familiar with OO perl and writing modules tho'. So if you don't know that learn that first.

      Absolutely! And I'd recommend checking out Damian Conway's Object Oriented Perl as a means of learning OO.

      Thanks for all the help guys, i've taken your advice and spent the afternoon reading up on OO and creating my own modules... gees there's a lot to learn... just when you think you're getting good at Perl, you find there's a whole load of stuff you didn't know even existed! hahaa. Well I knew OO existed, but still...

      Cheers, Tom

Re: Learning mod_perl
by bugsbunny (Scribe) on Jul 11, 2003 at 13:33 UTC
    what was the thing that bite's me most... is that every your page/script runs inside a sub() i.e.
    #mod_perl_handler sub handler { sub your_sub() {}.. ...your script.... }
    this means your subs runs as closures (this is very well explained into modperl docs)
    One disadventage of running this way is that u should use
    our $myvar;
    instead of :
    my $myvar;
    so that vars behave correctly inside your_sub() i.e. they become globals which is good for memory-conserving tehnique, but can be nasty if reused for other purposes by accident. In one email in the past I proposed to Stas Beckman, to use "goto"-variant instead of encompasing mod_perl_sub() so that this become non-issue.
    Pseudo code (by memory), havent used mod_perl long time:
    #mod_perl-handler package Blah; sub handler { keeping code... goto MYCODE } sub your_sub { .... } MYCODE: ...your code here....
      what was the thing that bite's me most... is that every your page/script runs inside a sub()

      This is only true if you're using the mod_perl Apache::PerlRun or Apache::Registry handlers - which are mainly used for the conversion of existing CGI based scripts to run under mod_perl.The CGI to mod_perl Porting of the mod_perl guide covers this.

      Once you start writing "native" mod_perl code the problem goes away.

        yep that is true, but most of time ppl write scripts directly using some framework like Apache::ASP, Apache::Registry, Apache::Perlrun etc.. instead of writing mod_perl handlers directly...:")
        Even if mod_perl stays the same, just with one simple options it can be done so that ppl may choose between these 2 variants... it is just a matter of string concatenation...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://273325]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2020-05-28 08:52 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (165 votes). Check out past polls.