Config-Fast

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    makes sense.

    Finally, if called in a scalar context, then variables will be imported
    directly into the "main::" namespace, just like if you had defined them
    yourself:

        use Config::Fast;

        fastconfig('web.conf');

        print "The web address is: $website\n";     # website from conf

    Generally, this is regarded as dangerous and bad form, so I would
    strongly advise using this form only in throwaway scripts, or not at
    all.

VARIABLES
    There are several global variables that can be set which affect how
    "fastconfig()" works. These can be set in the following way:

        use Config::Fast;
        $Config::Fast::Variable = 'value';
        %cf = fastconfig;

    The recognized variables are:

    $Delim
        The config file delimiter to use. This can also be specified as the
        second argument to "fastconfig()". This defaults to "\s+".

    $KeepCase
        If set to 1, then "MixedCaseVariables" are maintained intact. By
        default, all variables are converted to lowercase.

    $EnvCaps
        If set to 1 (the default), then any "ALLCAPS" variables are set as
        environment variables. They are still returned in lowercase from
        "fastconfig()".

    $Arrays
        If set to 1, then settings that look like shell arrays are converted
        into a Perl array. For example, this config block:

            MATRIX[0]="a b c"
            MATRIX[1]="d e f"
            MATRIX[2]="g h i"

        Would be returned as:

            $conf{matrix} = [ 'a b c', 'd e f', 'g h i' ];

        Instead of the default:

            $conf{matrix[0]} = 'a b c';
            $conf{matrix[1]} = 'd e f';
            $conf{matrix[2]} = 'g h i';

    @Define
        This allows you to pre-define var=val pairs that are set before the
        parsing of the config file. I introduced this feature to solve a
        specific problem: Executable relocation. In my config files, I put
        definitions such as:

            # Parsed by Config::Fast and sourced by shell scripts
            BIN="$ROOT/bin"
            SBIN="$ROOT/sbin"
            LIB="$ROOT/lib"
            ETC="$ROOT/etc"

        With the goal that this file would be equally usable by both Perl
        and shell scripts.

        When parsed by "Config::Fast", I pre-define "ROOT" to "pwd" before
        calling "fastconfig()":

            use Cwd;
            my $pwd = cwd;
            @Config::Fast::Define = ([ROOT => $pwd]);
            my %conf = fastconfig("$pwd/conf/core.conf");

        Each element of

    %Convert
        This is a hash of regex patterns specifying values that should be
        converted before being returned. By default, values that look like
        "true|on|yes" will be converted to 1, and values that match
        "false|off|no" will be converted to 0. You could set your own
        conversions with:

            $Config::Fast::CONVERT{'fluffy|chewy'} = 'taffy';

        This would convert any settings of "fluffy" or "chewy" to "taffy".

NOTES
    Variables starting with a leading underscore are considered reserved and
    should not be used in your config file, unless you enjoy painfully
    mysterious behavior.

    For a much more full-featured config module, check out
    "Config::ApacheFormat". It can handle Apache style blocks, array values,
    etc, etc. This one is supposed to be fast and easy.

VERSION
    $Id: Fast.pm,v 1.7 2006/03/06 22:18:41 nwiger Exp $

AUTHOR
    Copyright (c) 2002-2005 Nathan Wiger <nate@wiger.org>. All Rights
    Reserved.

    This module is free software; you may copy this under the terms of the
    GNU General Public License, or the Artistic License, copies of which
    should have accompanied your Perl kit.



( run in 0.651 second using v1.01-cache-2.11-cpan-71847e10f99 )