ConfHelper(3pm)

ConfHelper3pm

Configuration file management

Usage

  use ConfHelper;
  $file = new ConfHelper('myprogram', '/etc/myprogram.conf');

Overview

ConfHelper is a module that is designed to help you edit configuration files in an automated way without trampling on the toes of users or other programs. It does this by using "chunking"; that is, your program modifies a certain chunk of the config file and does not touch everything else. While this approach is not appropriate everywhere, it can be remarkably useful anyway.

The methods that return a chunk of data (an entire configuration area) return an array. Each element in the array is a single line that has been run through chomp(). When passed back to set() functions, the newline character is added back on before being written to disk.

Methods

new($package, $filename)

Creates a new object. The package parameter declares the name of your program or package, and the filename parameter specifies the name of the configuration file.

getversion

Returns the version of the ConfHelper module that created the object.

config($variable, $value)

Sets a configuration variable. The following are valid configuration variables:

startline

Specifies the complete text of the line that is used to identify the start of the ConfHelper section of your config file.

endline

Specifies the complete text of the line that is used to identify the end of the ConfHelper section of your config file.

hasconfarea

Returns 1 if the file has a configuration area, and 0 otherwise.

getconfarea

Returns your configuration area from the configuration file as a large array. If there is none, it returns undef.

getotherareas

Returns an array that represents all non-ConfHelper areas of your configuration file.

setconfarea(@confarea)

This method will set the configuration area to the value of the string passed as a parameter. ConfHelper will automatically rotate the file, saving backups of it.

setotherarea_DANGEROUS(@otherarea)

Sets the non-confarea portion of the file to the value specified. NOTE: THIS FUNCTION IS DANGEROUS AND SHOULD NOT BE USED UNLESS ABSOLUTELY NECESSARY! The configuration file is NOT rotated when this call is used.

Releases

3 releases since Debian 3.0 (Woody); the text changed 1 time.

  1. 3.0
  2. 3.1–4.0

Author

John Goerzen <[email protected]> of Progeny Linux Systems http://www.progeny.com.

From libconfhelper-perl 0.12.5 in Debian 4.0 (Etch). Parsed by carta from the page's man source.