Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Perl & Apache

  1. Dec 18, 2009 #1
    hey everyone,

    I'm a 3rd year uni student studying software engineering, and I recently got my first job working in an IT office at my school. One of my first assignments is to combine two Perl modules that deal with the Apache web server. I've never done work with Perl or Apache before, but I've been doing a lot of reading & coding since I was given this assignment. I've learned a lot in last couple of days (dude, the @_ array is such a cool feature!). I do have one question though (this will probably be the first in a series of questions on this assignment):

    Does anyone know of any good documentation that could give me some contextual information regarding how Perl works with Apache? I have a high-level understanding of how the server-client model works, but that's not enough. I found this, but I think it'll only be useful once I have a better idea of what exactly is going on: http://perl.apache.org/docs/1.0/api/Apache.html#The_Request_Object


  2. jcsd
  3. Dec 18, 2009 #2
    The basic way it works is just CGI. You can get into mod_perl, but you don't need to. Mod_perl is something to play with if you really get into it and have access to play with your Apache build. See http://httpd.apache.org/docs/2.2/howto/cgi.html.

    For Perl documentation I always keep http://perldoc.perl.org/index-functions-by-cat.html open. Actually, I lied. I use the condensed version at http://perldoc.perl.org/perlfunc.html#Perl-Functions-by-Category. The Perl Cookbook and "Camel Book" are good too. I use those in addition to the perldoc website. And don't forget to search CPAN, since the odds are someone has already written most of your code for you.

    There's really almost nothing at all to getting a Perl script to run in Apache. Let me know if you need anything besides what's there.
    Last edited by a moderator: Apr 24, 2017
  4. Dec 18, 2009 #3
    Oh, and the perl IRC channel on freenode is another good place to ask questions when you've checked the documentation and are still stuck.
  5. Dec 18, 2009 #4
    If you started with the mod_perl page because that's what the server and your scripts are using, then it's more complicated :tongue:. mod_perl just allows your perl programs to interface with the server more closely. It allows allows Apache to speed things up a lot under heavy load by only compiling scripts when necessary and not each time a page is loaded. It also allows your scripts to screw with Apache internals while it's running.

    Are your programs CGI or mod_perl based? Did you just go to the perl.apache.org (mod_perl) page because it said "perl"? I can recommend some mod_perl documentation if needed.
    Last edited: Dec 18, 2009
  6. Dec 19, 2009 #5
    Ah, this is great! Thanks so much! I'll definitely be looking into this some more. I'm not sure if my programs are CGI-based or mod_perl-based. Probably neither at this point because the Perl programs I've written so far are very basic (the most complicated one does some very basic file I/O stuff).

    As for books, I do have the "camel" book (I think it's called "Perl in a nutshell" or something). But the information on how Perl interacts with Apache is sparse at best in that book, I think.

  7. Dec 19, 2009 #6
    Programming Perl is the camel book :tongue:. Yeah, read the CGI page. There's almost nothing to interfacing the two. You just produce the html in your Perl script and the server runs it and displays the output to a browser.

    Don't worry about mod_perl or anything on the perl.apache.org site. Stick to httpd.apache.org.
  8. Jan 5, 2010 #7
    hey kote,

    After doing some more reading, it turns out that my scripts are mod_perl-based. So I was wondering if you could recommend some good mod_perl documentation?

    also, a quick question: What is "$r" in the context of mod_perl? Is it some kind of cookie that's sent to the server (just a guess based on what little I've read so far)?


Share this great discussion with others via Reddit, Google+, Twitter, or Facebook