gm_config -- read gm configuration
use gm_config;
gm_config is a simple module which provides general preference setting into
a
%config
hash. A set of KEY = VALUE
pairs are read from the ./.gm
file. The configuration hash is exported into the namespace of the calling
script.
Preferences are added simply by defining them in the configuration file.
The keys will be available in the %config
hash of a script that calls
gm_config
. Keys must only have alphanumeric characters. Line continuation is
currently not supported. Some additional functionality is provided.
... are recognized by a key that ends with DIR
. The config will check for a trailing slash, and tack one on if necessary.
... are recognized by a key that ends with FILE
. The config will check for a full path (ie. the presence of a slash in the
file name), and prepend './' if none is found.
... start with a '$', and end with the first occurrance of a non-alphanumeric character. If an environment variable exists with this name, it is expanded, otherwize the value is left as is.
... start with a '%', and end with the first occurrance of a
non-alphanumeric character. If the name is a valid (existing) key in %config
, it is expanded, otherwize the value is left as is. This means that the
variable definition must precede any references.
The order of expansion is per line, first environment variables, then configuration variables.
Comments start with '#', and run to the end of the line.
Lines that are not comments, but contain no '=' are ignored.
the file that contains general preferences. If one is not found in the current working directory, the calling script will fail to execute. The file format is
NAME = value
The (non-export) subroutine dump
prints the %config
hash on STDOUT
. Use it to see which variables are defined.
Make sure this module lives in some place that is present in the Perl module search path, for example by adding the location to the PERL5LIB environment variable.
There is some level of error checking (vagueness intentional). Progress and error messages are printed on STDERR, and should be self-explanatory.
Perl(1).
Probably..., no, very likely.
Joor Loohuis (loohuis@geo.uu.nl)
Copyright (c) 1999 Joor Loohuis. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.