NAME
PBib::Config - Configuration for PBib
SYNOPSIS
use PBib::Config;
$conf = new PBib::Config();
DESCRIPTION
Handle the configuration for PBib. It looks in cmd-line args, environment, and at various places at config files.
In fact, this module contains no code specific to PBib, so you might be able to use it for your own applications as well.
METHODS
- $conf = new PBib::Config(options)
-
New creates a new Config object. Upon creation, it reads the standard config from command-line, environment, site- and user-preferences. Options:
- argv
-
If true, check @ARGV.
- env
-
If true, check $ENV{'PBIB'};
- site
-
If true, read site configuration file ("local.pbib") -- whereever it is found ...
- user
-
If true, read user configuration file ("user.pbib") -- whereever it is found ...
- options
-
Ref to a hash with the default configuration.
- verbose
-
Be more verbose and keep the verbose flag within the options.
- quiet
-
Be more quite and keep the quiet flag within the options.
- $options = $conf->options(options)
-
Return a hash ref with all options. If the optional filename is given, it looks for additional options for this file by checking for a pbib.pbib file in this directory and for a file with .pbib as extension. Options:
- file
-
Look for additional options for this file in "$filename.pbib"
- dir
-
Look in this dir for additional "local.pbib"
- $option = $conf->option(name or path[, $new_val]);
-
Return the option.
If $new_val is given, the option is set to the new value and the old value is returned.
- $options = $conf->setOptions($options);
-
Overwrite the configuration stored internally.
- $verbose = $conf->beVerbose();
-
If true, more verbose output should be produced.
- $quiet = $conf->beQuiet();
-
If true, more quiet output should be produced.
- $options = $conf->load();
-
load config, as specified in new(). It will overwrite the configuration stored internally.
- SEARCH PATH for config files
-
the following places are searched for all config files:
- the current directory ('.')
- $HOME
-
If $HOME is set, pbib searches: $ENV{HOME}/.pbib/styles $ENV{HOME}/.pbib/conf $ENV{HOME}/.pbib $ENV{HOME}
- $PBIBSTYLES
-
Can be a comma separated list.
- $PBIBCONFIG
-
Can be a comma separated list.
- $PBIBPATH (separated by ',')
-
if $PBIBPATH is undefined, it defaults to /etc/pbib/styles,/etc/pbib/conf,/etc/pbib,/etc
- $APPDATA
-
$APPDATA is supported for Windows XP. If set, pbib searches $ENV{APPDATA}/PBib/styles $ENV{APPDATA}/PBib/conf $ENV{APPDATA}/PBib
- $PBIBDIR
-
if $PBIBDIR is undefined, it defaults to the directory pbib resides in (as detected by FindBin).
- all PBib/styles and PBib/conf in @INC
-
Perl's include path @INC is searched for all subdirectories PBib/styles and PBib/conf. This is where the an installed PBib finds all the default configuration.
Note: by using all these places for every config file, it is possible for each user to overwrite the site's configuration if necessary. Use with care!
- $options = $conf->merge($options);
CLASS METHODS
- $hash_ref = merge_options(<<array of hash refs>>)
-
Return an hash with all merged options entries. This also traverses sub-entry hashs.
Parameters that are no hash refs are ignored. Duplicate keys will be overwritten depending on the order of parameters.
AUTHOR
Peter Tandler <pbib@tandlers.de>
SEE ALSO
Module PBib::PBib
HISTORY
$Log: Config.pm,v $ Revision 1.7 2003/06/16 09:12:28 tandler use default.pbib that contains config that was previously directly in the perl source
Revision 1.6 2003/06/13 16:11:09 tandler moved default local.pbib to "conf" folder
Revision 1.5 2003/04/16 15:06:09 tandler adapted to support search path for config files in patched Config::General
Revision 1.4 2003/04/14 09:46:12 ptandler new module ConfigFile that encapsulates Config::General
Revision 1.3 2003/02/20 09:26:41 ptandler added dirs to look for config files: - $ENV{PBIBDIR} (if set instead of $Bin), - $ENV{PBIBPATH} or /etc/pbib - $ENV{PBIBSTYLES} - $ENV{PBIBCONFIG}
Revision 1.2 2003/01/14 11:08:15 ptandler new config
Revision 1.1 2002/11/11 12:00:51 peter early stage ...