Documentation, examples, tutorials and more

<<

NAME

Smash::Config::Parser - Generic config parser.

SYNOPSIS

        use Smash::Config::Parser;
        my $parser = new Smash::Config::Parser("smash.conf");
        my $conf1  = $parser->parse();    # defaults to : as delimiter
        my $conf2  = $parser->parse("="); # explicitly sets = as delimiter
        print $conf1->{"Taxonomy"}->{"data_repos"};

DESCRIPTION

Smash::Config::Parser is a generic parser with specific application to parse the Smash config file. The format of this file is:

        # Comments can go anywhere in a line that starts with a '#'.
        # Internal comments like perl, where a '#' symbol followed 
        #   by comments at the end of the line, are not recognized.
        # And empty lines don't matter.

        [Section1]
        key1    : value1
        # This comment is fine
        key2    : value2

        [Section2]
        key1    : value1
        key2    : value2 # This comment is NOT fine.
        key3    : value3 # This is part of value.

FUNCTIONS

parse($delimiter)

Once the object is made with the FILE attribute, this function parses the file using the given delimiter, or by default colon (:). If there are multiple instances of delimiter, the first one is used as the real delimiter and what follows (including the other instances of the delimiter) will be stored as the value of the key. All keys and values will be trimmed for whiltespace in the ends. It then returns a pointer to a multilevel hash that can be queried as $conf-{section}->{key}>.

<<