NAME

gm_config -- read gm configuration


SYNOPSIS

    use gm_config;


DESCRIPTION

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.


Key Recognition

Directory preferences...

... are recognized by a key that ends with DIR. The config will check for a trailing slash, and tack one on if necessary.

File preferences...

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


Variable Expansion

Environment variables...

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

Configuration variables...

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


Miscellaneous

Comments start with '#', and run to the end of the line.

Lines that are not comments, but contain no '=' are ignored.


FILES

./.gm

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


NOTES

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.


DIAGNOSTICS

There is some level of error checking (vagueness intentional). Progress and error messages are printed on STDERR, and should be self-explanatory.


SEE ALSO

Perl(1).


BUGS

Probably..., no, very likely.


AUTHOR

Joor Loohuis (loohuis@geo.uu.nl)


COPYRIGHT

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.