CONFIG::Hash - Class to read 2-column files into a hash

perldoc CONFIG::Hash

[ Back | Up ]

NAME

CONFIG::Hash - Class to read 2-column files into a hash

[ Back | Up ]

SYNOPSIS

   use CONFIG::Hash;

   my $file = CONFIG::Hash->new($filename, \%config);

   $hash_ref = $file->get();

   $value = $file->get($key);

[ Back | Up ]

DESCRIPTION

Parses a two-column formated file into a hash. The module uses the CONFIG::Plain class so you can use all features of the Plain module.

[ Back | Up ]

METHODS

[ Back | Up ]

new - parse file (read via CONFIG::Plain) into hash

Configuration Options:

   -> all described in CONFIG::Plain are known

   KEYREGEXP

        Scalar holding a regular expression which must match every key.

        DEFAULT: "^(\\S+)"

        HINT: Since the first character of a line has to be a non-white-space
              character it is possible to make multi-line values.
              Have a look at the examples.

   HASHREGEXP

        Scalar holding a regular expression which matches the content.

        DEFAULT: "\\s+(.*)\$"

   SUBSTITUTENEWLINE

        If defined all NewLine characters in the value will be substituted
        with this scalar.

        DEFAULT: "\n"
        
   REQUIRE

        Reference to a Array which holds list of required variables.

        DEFAULT: []

   DEFAULT
        
        Reference to Hash holding default Values.

        DEFAULT: {}

   ALLOWREDEFINE

        Scalar switch to suppress error messages if the same key is
        redefined at a later point in file.

        DEFAULT: 1

   CASEINSENSITIVE

        All keys are convertet into lower case if this option was defined.

        DEFAULT: undef

[ Back | Up ]

get - get a reference to the hash or a specified field

   $hash_ref = $file->get();

      Returns a reference to the hash holding all data from file.

   $value = $file->get($key);

      Returns the value to the specified key.

[ Back | Up ]

get_line - get the linenumber where this key was found

   $line_nr = $file->get_line($key);
 
      Returns a scalar holding the line number. Call often to get
      include path.

[ Back | Up ]

get_file - get the filename where this key was found

   $filename = $file->get_file($key);

      Returns a scalar holding the filename. Call often to get
      include path.

[ Back | Up ]

EXAMPLES

        Assumes default configuration

        >KEY    This is a very stupid text
        >       but it shows the functionality \
        >       of this module

        Will get into
        'KEY' => "This is a very stupid text\nbut it shows the functionality of this module"

        With the config setting 'SUBSTITUTENEWLINE' => ' '
        
        >INSERT insert into 
        >       table dummy
        >               (col1, col2, col3)
        >       values
        >               (1, "value", "value2");

        Will get into
        'INSERT' => 'insert into table dummy (col1, col2, col3) values (1, "value", "value2");'

[ Back | Up ]

SEE ALSO

CONFIG::Plain(3pm)

[ Back | Up ]

COPYRIGHT

    Copyright (C) 1999, 2000 by Markus Winand <>

    This program is free software; you can redistribute it and/or
    modify it under the same terms as Perl itself.

 

Do not use offset for pagination. Learn why.

About

Last modification:
Fri Nov  6 23:32:51 2009
Informationen zu E-Commerce und Mediengesetz