NAME FML::Config -- manipulate fml8 configuration name space. SYNOPSIS $config = new FML::Config; # get the current value $config->{recipient_maps}; # set the new value $config->{recipient_maps} = 'mysql:toymodel'; # function style to get/set the value for the key "recipient_maps" $config->get('recipient_maps'); $config->set('recipient_maps', 'mysql:toymodel'); DESCRIPTION DATA STRUCTURE $curproc hash holds the CURrent PROCess information. It contains several references to other data structures. $curproc = { # configurations config => C, # struct incoming_message holds the mail input from STDIN. incoming_message => C, ... }; DELAYED VALUE EXPANSION data manipulation of set() and get() is assymetric and asynchronous. "set(key,value)" saves the value for a key in %fml_config. "get(key)" returns the value for a key in %fml_config_result, which is value expanded from %fml_config. The expansion is done when "get()" is called not when "set()" is called. METHODS new($cfargs) special method used only in the fml initialization phase. This method binds $curproc and the %$_fml_config hash on memory. Internally this method uses "tie()" to get and set a key to a value. For example, "get()" and "set()" described below is a wrapper for tie() IO. "NOTE:" pseudo variable "_pid" is reserved for process id reference. get( key ) get value for key. return '' (null string) if undefined. get_as_array_ref( key ) get value for key as an array reference. return [] if undefined. set( key, value ) set value for key. overload( filename ) alias of "load_file( filename )". load_file( filename ) read the configuration file, split keys and the values in it and set them to %$_fml_config. read(file) read configuration from the specified file. Internally it holds configuration and comment information in appearing order. write(file) expand_variables() expand all variables in %$_default_fml_config and %$_fml_config. The expanded result is saved in the same hash. XXX obsolete ? This method is used before hook is introduced. XXX Consider a hook may change the variable. XXX We should expand variables on demand in that case expand_variable_in_buffer($rbuf) expand $varname to $config->{ varname } in $rbuf. yes( key ) useful method to return 1 or 0 according the value to the given key. no( key ) useful method to return 1 or 0 according the value to the given key. has_attribute( key, attribute ) Some types of "key" has a list as a value. If "key" has the "attribute" in the list, return 1. return 0 if not. as_second($key) return the value as seconds such as 86400 for '1d'. dump_variables($cfargs) show all {key => value} for debug. You can specify options at $cfargs. Specify all at mode to dump all variables. $cfargs = { mode => all }; Specify get_diff_as_hash_ref at mode to show only variables differed from the original one. $cfargs = { mode => get_diff_as_hash_ref }; Dump only variables differed from the original one to STDOUT when other mode specified. HOOK manipulations $config->is_hook_defined( 'START_HOOK' ); $config->get_hook( 'START_HOOK' ); is_hook_defined( $hook_name ) whether hook named as $hook_name is defined or not? CONTEXT SWITCHING set_context($context) set up context identifier. get_context return context identifier. TIEED HASH tie() operations for hash are binded to $_fml_config. For example, "get()" and "set()" described above is a wrapper for tie() IO. ERROR METHODS error_set($message) save $message as an error message. error() return $message which is saved by "error_set($msg)". error_clear() clear the error message buffer. CODING STYLE See "http://www.fml.org/software/FNF/" on fml coding style guide. AUTHOR Ken'ichi Fukamachi COPYRIGHT Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2011 Ken'ichi Fukamachi All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. HISTORY FML::Article first appeared in fml8 mailing list driver package. See "http://www.fml.org/" for more details.