Learning Perl & Apache for a Uni Assignment

AI Thread Summary
A third-year software engineering student has started a job in an IT office, where he is tasked with combining two Perl modules for the Apache web server. Despite having no prior experience with Perl or Apache, he has been actively learning and is particularly interested in understanding how Perl interacts with Apache. He seeks documentation that provides contextual information about this integration. Responses suggest focusing on CGI for basic scripts and recommend various resources, including perldoc, the Perl Cookbook, and mod_perl documentation. The discussion highlights the simplicity of running Perl scripts in Apache and clarifies that mod_perl enhances performance by allowing scripts to interface more closely with the server. The student later confirms that his scripts are mod_perl-based and inquires about specific mod_perl documentation and the meaning of "$r" in this context.
Chromium
Messages
56
Reaction score
0
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

thanks,

--Jonathan
 
Technology news on Phys.org
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:
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.
 
If you started with the mod_perl page because that's what the server and your scripts are using, then it's more complicated :-p. 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:
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.

--Jonathan
 
Chromium said:
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.

--Jonathan

Programming Perl is the camel book :-p. 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.
 
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)?

thanks!

--Jonathan
 
Back
Top