ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы.



Perl in a Nutshell

Perl in a NutshellSearch this book
Previous: 11.5 Server-Side Includes with mod_perlChapter 11
Web Server Programming with mod_perl
Next: 11.7 Apache:: Modules
 

11.6 <Perl> Sections

With mod_perl, you can use Perl in Apache configuration files. What this means is that you can make your Apache configuration much more flexible by using conditionals.

Any Perl code in Apache configuration files should be placed between <Perl> and </Perl> directives. This code can define variables and lists that are used by mod_perl to assign the associated Apache configuration directives; for example, assigning the $ServerAdmin variable will redefine the ServerAdmin Apache configuration directive.

Suppose you share the same Apache configuration files across multiple servers, and you only want to allow personal directories on one of them. You can use Perl directives like this:

<Perl>
if (`hostname` =~ /public/) {
	$UserDir = "public.html";
} else {
	$UserDir = "DISABLED";
}
1;
</Perl>
Directive blocks (such as <Location>...</Location\>) can be represented as a hash. For example:
<Perl>
$Location{"/design_dept/"} = {
	DefaultType   => 'image/gif',
	FancyIndexing => 'On'
}
</Perl>


Previous: 11.5 Server-Side Includes with mod_perlPerl in a NutshellNext: 11.7 Apache:: Modules
11.5 Server-Side Includes with mod_perlBook Index11.7 Apache:: Modules