1Config::Tiny(3)       User Contributed Perl Documentation      Config::Tiny(3)
2
3
4

NAME

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

SYNOPSIS

10           # In your configuration file
11           rootproperty=blah
12
13           [section]
14           one=twp
15           three= four
16           Foo =Bar
17           empty=
18
19           # In your program
20           use Config::Tiny;
21
22           # Create a config
23           my $Config = Config::Tiny->new();
24
25           # Open the config
26           $Config = Config::Tiny->read( 'file.conf' );
27
28           # Reading properties
29           my $rootproperty = $Config->{_}->{rootproperty};
30           my $one = $Config->{section}->{one};
31           my $Foo = $Config->{section}->{Foo};
32
33           # Changing data
34           $Config->{newsection} = { this => 'that' }; # Add a section
35           $Config->{section}->{Foo} = 'Not Bar!';     # Change a value
36           delete $Config->{_};                        # Delete a value or section
37
38           # Save a config
39           $Config->write( 'file.conf' );
40

DESCRIPTION

42       "Config::Tiny" is a perl class to read and write .ini style
43       configuration files with as little code as possible, reducing load time
44       and memory overhead. Most of the time it is accepted that Perl
45       applications use a lot of memory and modules. The "::Tiny" family of
46       modules is specifically intended to provide an ultralight alternative
47       to the standard modules.
48
49       This module is primarily for reading human written files, and anything
50       we write shouldn't need to have documentation/comments. If you need
51       something with more power move up to Config::Simple, Config::General or
52       one of the many other "Config::" modules. To rephrase, Config::Tiny
53       does not preserve your comments, whitespace, or the order of your
54       config file.
55

CONFIGURATION FILE SYNTAX

57       Files are the same format as for windows .ini files. For example:
58
59               [section]
60               var1=value1
61               var2=value2
62
63       If a property is outside of a section at the beginning of a file, it
64       will be assigned to the "root section", available at "$Config->{_}".
65
66       Lines starting with '#' or ';' are considered comments and ignored, as
67       are blank lines.
68
69       When writing back to the config file, all comments, custom whitespace,
70       and the ordering of your config file elements is discarded. If you need
71       to keep the human elements of a config when writing back, upgrade to
72       something better, this module is not for you.
73

METHODS

75   new
76       The constructor "new" creates and returns an empty "Config::Tiny"
77       object.
78
79   read $filename
80       The "read" constructor reads a config file, and returns a new
81       "Config::Tiny" object containing the properties in the file.
82
83       Returns the object on success, or "undef" on error.
84
85       When "read" fails, "Config::Tiny" sets an error message internally you
86       can recover via "<Config::Tiny-"errstr>>. Although in some cases a
87       failed "read" will also set the operating system error variable $!, not
88       all errors do and you should not rely on using the $! variable.
89
90   read_string $string;
91       The "read_string" method takes as argument the contents of a config
92       file as a string and returns the "Config::Tiny" object for it.
93
94   write $filename
95       The "write" method generates the file content for the properties, and
96       writes it to disk to the filename specified.
97
98       Returns true on success or "undef" on error.
99
100   write_string
101       Generates the file content for the object and returns it as a string.
102
103   errstr
104       When an error occurs, you can retrieve the error message either from
105       the $Config::Tiny::errstr variable, or using the "errstr()" method.
106
107   property_string
108       This method is called to produce the string used to represent the
109       property in a section.  It is passed the section name and property
110       name.
111
112   set
113       This is a convenience is called to set a value found in the parsed
114       config string.  It is passed the section name, property name, and
115       value.
116

SUPPORT

118       Bugs should be reported via the CPAN bug tracker at
119
120       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Config-Tiny>
121
122       For other issues, or commercial enhancement or support, contact the
123       author.
124

AUTHOR

126       Adam Kennedy <adamk@cpan.org>
127

ACKNOWLEGEMENTS

129       Thanks to Sherzod Ruzmetov <sherzodr@cpan.org> for Config::Simple,
130       which inspired this module by being not quite "simple" enough for me :)
131

SEE ALSO

133       Config::Simple, Config::General, ali.as
134
136       Copyright 2002 - 2007 Adam Kennedy.
137
138       This program is free software; you can redistribute it and/or modify it
139       under the same terms as Perl itself.
140
141       The full text of the license can be found in the LICENSE file included
142       with this module.
143
144
145
146perl v5.10.1                      2007-11-02                   Config::Tiny(3)
Impressum