books
Free Books / Computers / Practical mod_perl /

previous page: 4.4.1. Constructing <Perl> Sections
  
page up: Practical mod_perl | by Stas Bekman and Eric Cholet
  
next page: 4.4.3. Cheating with Apache->httpd_conf

4.4.2. Breaking Out of <Perl> Sections




Description

This section is from the "Practical mod_perl" book, by Stas Bekman and Eric Cholet. Also available from Amazon: Practical mod_perl

Behind the scenes, mod_perl defines a package called Apache::ReadConfig in which it keeps all the variables that you define inside the <Perl> sections. So <Perl>sections aren't the only way to use mod_perl to configure the server: you can also place the Perl code in a separate file that will be called during the configuration parsing with either PerlModule or PerlRequire directives, or from within the startup file. All you have to do is to declare the package Apache::ReadConfig before writing any code in this file.

Using the last example from the previous section, we place the code into a file named apache_config.pl, shown in Example 4-4.

Example 4-4. apache_config.pl

package Apache::ReadConfig;

use Sys::Hostname;
$ServerName = hostname( );
if ($ServerName !~ /^secure/) {
    $UserDir = "public.html";
}
1;

Then we execute it either from httpd.conf:

PerlRequire /home/httpd/perl/lib/apache_config.pl

or from the startup.pl file:

require "/home/httpd/perl/lib/apache_config.pl";

 

Continue to:

  • prev: 4.4.1. Constructing <Perl> Sections
  • Table of Contents
  • next: 4.4.3. Cheating with Apache->httpd_conf

Books by Stas Bekman:















TOP
previous page: 4.4.1. Constructing &lt;Perl&gt; Sections
  
page up: Practical mod_perl | by Stas Bekman and Eric Cholet
  
next page: 4.4.3. Cheating with Apache-&gt;httpd_conf

Topics

  • Animals
  • Architecture
  • Arts
  • Business
  • Computers
  • Crafts
  • Fairy Tales
  • Finance
  • Flora and Plants
  • Cooking
  • Gardening
  • Health and Healing
  • History
  • Home Improvements
  • Languages
  • New Age
  • Novels
  • Real Estate
  • Reference
  • Religion
  • Science
  • Society
  • Sports
  • Travel
  • Outdoors


Search

My Books

Headaches Begone! A Systemic Approach To Healing Your Headaches
Don't Let Your Bike Seat Ruin Your Sex Life Book

Discover

  • Answers FAQ

[ Privacy Policy | Terms of Use | About Us | Search ]

© 2007-2021 StasoSphere.com