☺唐鳳☻
and 1 contributors

NAME

Config::Tiny - Read/Write .ini style files with as little code as possible

SYNOPSIS

    # In your configuration file
    rootproperty=blah

    [section]
    one=twp
    three= four
    Foo =Bar
    empty=

    # In your program
    use Config::Tiny;

    # Create a config
    my $cfg = new();

    # Open the config
    $cfg<read>( 'cfg.ini' ) || die $cfg<err_str>();

    # Reading properties 
    my $rootproperty = $cfg<data>(){''}<rootproperty>; # Syntax below is nicer 

    my $data = $cfg<data>();
    my $one = $data<section><one>;
    my $Foo = $data<section><Foo>;

    # Changing data
    $cfg<data>()<newsection> = { 'this' => 'that' }; # Add a section - Syntax below is nicer 

    my $data = $cfg<data>();
    $data<section><Foo> = 'Not Bar!';                # Change a value
    delete $data{''};                                # Delete a value or section

    # Save a config
    $cfg<write>( 'new.ini' );

DESCRIPTION

Config::Tiny is a utility to read and write .ini style configuration files with as little code as possible, reducing load time and memory overhead.

Written using Pugs as of 2005-05-05, it was written to provide functionality while Perl6 was still being developed.

This module is primarily for reading human written files, and anything we write shouldn't need to have documentation/comments. If you need something with more power, move up to Config::Simple, Config::General or one of the many other Config:: modules. To rephrase, Config::Tiny does not preserve your comments, whitespace, or the order of your config file.

CONFIGURATION FILE SYNTAX

Files are the same as windows .ini files, for example.

        [section]
        var1=value1
        var2=value2

If a property is outside of a section, it will be assigned to the root section, available at $config<data>{''}.

Lines starting with '#' or ';' are comments, and blank lines are ignored.

When writing back to the config file, any comments are discarded.

METHODS

Since the current version of Pugs does not support OO, methods are implemented as hash keys to code refs. The only function this module exports is the constructor.

Config::Tiny::new

The constructor Config::Tiny::new creates and returns an empty Config::Tiny (pseudo) object.

NOTE: To avoid name collisions, we use a fully qualified function name.

The following are the (pseudo) methods for Config::Tiny objects. These methods can be called with the following syntax:

  $config<read>('config.ini');
  

where $config is an 'instance' returned by the Config::Tiny::new constructor.

read ($filename)

The read method reads a config file, and returns a boolean value of success or failure

data

The data method returns a hash reference representing the configuration data

write

The write method the file for the properties, and writes it to disk. Returns boolean value of success or failure;

err_str

The err_str method returns the last error message

AUTHORS

This module is based on Adam Kennedy's Perl5 module by the same name

Joshua Gatcomb, <Limbic_Region_2000@Yahoo.com>

Stevan Little, <stevan@iinteractive.com>

SEE ALSO

Adam's Perl5 implementation

http://search.cpan.org/~adamk/Config-Tiny-2.01/lib/Config/Tiny.pm

OO Perl6 implementation by Ingo Blechschmidt

http://tpe.freepan.org/repos/adamk/Config-Tiny/lib/Config/Tiny.pm

COPYRIGHT

Copyright (c) 2005 Joshua Gatcomb. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.