BIND::Conf_Parser implements a virtual base class for parsing BIND (Berkeley Internet Name Domain) server version 8 configuration files ("named.conf"). The parsing methods shown in the synopsis perform syntactic analysis only. As each meaningful semantic 'chunk' is parsed, a callback method is invoked with the parsed information. The following methods are the public entry points for the base class:

The given filehandle is parsed in its entirety. An optional filename may be given for inclusion in any error messages that are generated during the parsing. If it is not included a default of "a file handle" will be used.

The given scalar is parsed in its entirety. Partial statements will be treated as a syntax error. An optional filename may be given for inclusion in any error messages that are generated during the parsing. If it is not included a default of "a scalar" will be used.

For conveniance, the last three methods may also be called as class methods (that is, with the class name instead of a constructed object reference), in which case they will call new() method and use the resulting object. All three return the object used, whether passed in or constructed at call-time.

In order to make the parser useful, you must make a subclass where you override one or more of the following methods as appropriate:

BIND::Conf_Parser does not perform all the syntactic checks performed by the parser in named itself. For example, port numbers are not verified to be positive intergers in the range 0 to 65535.

The parse() method cannot be called multiple times with parts of statements.

Comments are not passed to a callback method.

Some callbacks are invoked before the semicolon that terminates the corresponding syntactic form is actually recognized. It is therefore possible for a syntax error to not be detected until after a callback is invoked for the presumably completly parsed form. No attempt is made to delay the invocation of callbacks to the completion of toplevel statements.

This version of BIND::Conf_Parser corresponds to BIND version 8.2.2 and understands the statements, options, and forms of that version. Since the BIND developers have only made upward compatible changes to the syntax, BIND::Conf_Parser will correctly parse valid config files for previous versions of BIND.

A BIND::Conf_Parser object is a blessed anonymous hash. In an attempt to prevent modules trampling on each other I propose that any subclass that requires persistant state between calls to the callback routines (handle_foo()) and other subclass methods should prefix its keys names with its own name separated by _'s. For example, a hypothetical BIND::Conf_Parser::Keys module would keep data under keys that started with 'bind_conf_parser_keys_', e.g., 'bind_conf_parser_keys_key_count'. The 'state' key is reserved for use by application specific one-shot parsers (this is expected to encompass most uses of BIND::Conf_Parser). BIND::Conf_Parser reserves for itself all keys beginning with an underbar.

This library is free software; you can redistribute it and/or This program is free software; redistribution and modification in any form is explicitly permitted provided that all versions retain this copyright notice and the following disclaimer.

This library 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.