Apache::Admin::Config 0.07 ========================== INSTALLATION To install this module type the following: perl Makefile.PL make make test make install CHANGES 0.07 Thu Sep 20 02:36:17 2001 - Major change, section and directive methods no any longer return an arrayref in list context but a simple list. Documentation corrected (thanx to Nathan Wiger for this suggestion). 0.06 Tue Sep 18 01:09:24 2001 - Make a quick and dirty documentation - value() return the context value if no arguments given - new() can be called without argument, save() need an argument in this case 0.05 Sat Aug 18 14:39:45 2001 - Major bug fix, if config file wasn't exists, module won't work ! - Bug fix, value method wasn't took the appropriate value for change it, resulted to an unchanged value - Bug fix, $master and $root value was undefined in value method, so value wasn't work at all 0.04 Fri Aug 17 01:42:16 2001 - Fix a minor bug in directive method. 0.03 Fri Aug 17 01:07:17 2001 - Fix a major bug in directive method. 0.02 Thu Aug 16 01:48:54 2001 - Put module on CPAN - Fix a very major bug that cause "syntax error" from parser on directives with no value like "clearmodulelist", thanx A2 for this report. 0.01 Sun Aug 12 11:58:10 2001 - Original version; created by h2xs 1.21 with options -AX -n Apache::Admin NAME Apache::Admin::Config - A common module to manipulate Apache configuration files SYNOPSIS use Apache::Admin::Config; my $obj = new Apache::Admin::Config ("/path/to/config_file.conf") || die $Apache::Admin::Config::ERROR; # getting the full list of directives in current context die if error # (don't use || instead of "or" here !!) my @directives_list = $obj->directive or die $obj->error; # getting the full list of sections in current context or die if error # (don't use || instead of "or" here !!) my @sections_list = $obj->section or die $obj->error; # getting values' list of directive "Foo" my @foo_directive_values = $obj->directive('Foo'); # getting values' list of section "Foo" my @foo_section_values = $obj->section('Foo'); # adding directive "Foo" with value "bar" in the current context $obj->add_directive(Foo=>'bar'); # adding directive "Foo" with value "bar" in the section # of current context $obj->section(VirtualHost=>'test.com')->add_directive(Foo=>'bar'); # adding section "Foo" with value "bar" in the current context $obj->add_section(Foo=>'bar'); # adding section "Foo" with value "bar" in the section # of current context (in two steps) my $subsection = $obj->section(VirtualHost=>'test.com'); $subsection->add_section(Foo=>'bar'); # change directive "Foo" with value "bar" to value "rab" $obj->directive(Foo=>'bar')->value('rab'); # same in sub-section $obj->section(VirtualHost=>'test.com')->directive(Foo=>'bar')->value('rab'); # change section "Foo" with value "bar" to value "rab" $obj->section(Foo=>'bar')->value('rab'); # delete directive "Foo bar" (the last one if serveral identicales) $obj->directive(Foo=>'bar')->delete; # delete section "..." (all sections if dispatched several # sections with same name/value) $obj->section(Foo=>'bar')->delete; # save changes in the file $apache_conf->save; # or in another file $apache_conf->save('/path/to/another/file.conf'); DESCRIPTION This module allows you to edit Apache configuration files without modifying comments, indentation, or truncated lines. METHODES new [/path/to/file] Create or read, if given in argument, an apache like configuration file. save [/path/to/file] Write modifications to the configuration file. If a path to a file is given, save the modification to this file instead. add_section $obj->add_section(foo=>'bar') Add the section named "foo" with value "bar" to the context pointed by $obj. section [name], [value] @sections_list = $obj->section; @section_values = $obj->section(SectionName); $section_object = $obj->section(SectionName=>'value'); arguments: name : the name of section, it's "File" in section value : the value of the section This method return : - list of sections in current context if no argument is given. - list of sections "foo"'s values if the only argument is "foo". return a list in list context and a reference to an array in scalar context. - an object for the context pointed by the section "foo" with value "bar" if arguments given was "foo" and "bar". add_directive $obj->add_directive(foo=>'bar'); Add the directive "foo" with value "bar" in the context pointed by $obj. directive @directives_list = @{ $obj->directive }; @directive_values = @{ $obj->directive(Foo); $directvie_object = $obj->directive(Foo=>'bar'); Arguments: name : the name of directive. value : value of the directive. This method return : - list of directives in context pointed by $obj if no argument is given. return a list in list context and a reference to an array in scalar context. - list of "foo" directive's values if the only argument is "foo". return a list in list context and a reference to an array in scalar context. - an object for manipulating directive called "foo" with value "bar" if arguments given was "foo" and "bar". Warning, if several directive have the same name and value, the last one is taken, may change in future versions. delete $htconf->directive('AddType'=>'.pl')->delete; $htconf->section('File'=>'/path/to/file')->delete; Delete the current context pointed by object. Can be directive or section. value [newvalue] $htconf->directive('File'=>'/path/to/foo')->value('/path/to/bar'); Change the value of a directive or section. If no argument given, return the value of object $htconf. error Return the last append error. AUTHOR Olivier Poitrey LICENCE This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc. : 59 Temple Place, Suite 330, Boston, MA 02111-1307 COPYRIGHT Copyright (C) 2001 - Olivier Poitrey HISTORY $Log: README,v $ Revision 1.11 2001/09/20 00:52:26 rs *** empty log message *** Revision 1.10 2001/09/20 00:51:55 rs on the way of O.07 release Revision 1.20 2001/09/20 00:43:31 rs don't confuse array and list ! Revision 1.18 2001/09/20 00:25:59 rs section and directive now return an array if called in array context Revision 1.17 2001/09/17 23:44:06 rs minor bugfix Revision 1.16 2001/09/17 23:12:53 rs Make a real quick and dirty documentation value() now return the context value if called without arguments new() can now be called without arguments, save() need one in this case Revision 1.15 2001/08/23 01:05:35 rs update of documentation's DESCRIPTION section Revision 1.14 2001/08/18 13:38:25 rs fix major bug, if config file wasn't exist, module won't work Revision 1.13 2001/08/18 12:50:14 rs value method wasn't take the appropriate value for change it Revision 1.12 2001/08/18 12:46:15 rs $root value was not defined ! Revision 1.11 2001/08/18 12:39:35 rs migrate to 0.05 Revision 1.10 2001/08/18 12:39:15 rs bug fix in value method, $master wasn't defined, cause method to not work at all Revision 1.9 2001/08/16 23:41:59 rs fix bug in directive method : directive foo doesn't exists @{$conf->directive("foo")}; $conf->add_directive(foo=>'bar'); Modification of non-creatable array value attempted, subscript -1 at ... line 358. Revision 1.8 2001/08/16 23:07:04 rs fix a bug in directive methode. Revision 1.7 2001/08/15 23:48:33 rs Fix a major bug that cause "syntaxe error" on directives that haven't values like "clearmodulelist" Revision 1.6 2001/08/14 09:49:07 rs adding some pod sections