As described in Chapter 7, it's possible to configure the Apache server entirely via Perl scripts embedded in <Perl> sections. The Apache::PerlSections module is a helper class that provides convenient functions for this process. It provides two public functions, dump( ) and store( ).
Called from within a <Perl> configuration section, dump( ) returns a pretty-printed string containing the current configuration variables. The string can be written out to a file and later brought back in via a require.
<Perl> use Apache::PerlSections (); $Port = 8529; @DocumentIndex = qw(index.htm index.html); print Apache::PerlSections->dump(); </Perl>
This will print out something like this:
package Apache::ReadConfig; #scalars: $Port = 8529; #arrays: @DocumentIndex = ( 'index.htm', 'index.html' ); # hashes 1; __END__
Notice that the variables are declared in the Apache::ReadConfig package. We give the reason for this in the next section.
This is identical to dump( ), except that the formatted string is written directly to the file path you specify.
<Perl> ..... print Apache::PerlSections->store('httpd_config.pl'); </Perl>
If a relative path is given to store(), it will be taken as relative to the current configuration file.