The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Tie::ConfigFile - Tie configuration file to a hash

SYNOPSIS

    use Tie::ConfigFile;

    my %hash;
    tie %hash, 'Tie::ConfigFile', filename => 'foobar.conf', readonly => 0;

    $hash{foo} = 'bar'; # will be written to foobar.conf

    untie %hash;

DESCRIPTION

This module allows you to tie configuration file to a hash. To understand what "tie" means in this context, read perltie. Comments in configuration files are NOT supported.

OPTIONS

  • filename (string, mandatory) - Path to a configuration file.

  • create_file (boolean, default: 0) - Try to create configuration file if it doesn't exist.

  • die_on_error (boolean, default: 1) - Croak when error happens.

  • empty_is_undef (boolean, default: 1) - If key does exist but there is no value, return undef on retrieval.

  • readonly (boolean, default: 1) - Disallow writing to the config file.

  • separator (string, default: =) - Key and value separator in config file. If specified separator and separator used in config file are different, said file will get corrupted on write.

EXPORT

Nothing is exported.

CAVEATS

When more than one process uses configuration file in non-readonly mode, data loss may happen.

SEE ALSO

FOSSIL REPOSITORY

DBD::IngresII Fossil repository is hosted at xenu.tk:

    http://code.xenu.tk/repos.cgi/tie-configfile

AUTHOR

    Tomasz Konojacki <me@xenu.tk>

COPYRIGHT AND LICENSE

Copyright (C) 2014 by Tomasz Konojacki

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.18.2 or, at your option, any later version of Perl 5 you may have available.