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 pos‐
7       sible
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 configura‐
43       tion files with as little code as possible, reducing load time and mem‐
44       ory overhead. Most of the time it is accepted that Perl applications
45       use a lot of memory and modules. The "::Tiny" family of modules is
46       specifically intended to provide an ultralight alternative to the stan‐
47       dard 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 con‐
54       fig 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
77       The constructor "new" creates and returns an empty "Config::Tiny"
78       object.
79
80       read $filename
81
82       The "read" constructor reads a config file, and returns a new "Con‐
83       fig::Tiny" object containing the properties in the file.
84
85       Returns the object on success, or "undef" on error.
86
87       When "read" fails, "Config::Tiny" sets an error message internally you
88       can recover via "<Config::Tiny-"errstr>>. Although in some cases a
89       failed "read" will also set the operating system error variable $!, not
90       all errors do and you should not rely on using the $! variable.
91
92       read_string $string;
93
94       The "read_string" method takes as argument the contents of a config
95       file as a string and returns the "Config::Tiny" object for it.
96
97       write $filename
98
99       The "write" method generates the file content for the properties, and
100       writes it to disk to the filename specified.
101
102       Returns true on success or "undef" on error.
103
104       write_string
105
106       Generates the file content for the object and returns it as a string.
107
108       errstr
109
110       When an error occurs, you can retrieve the error message either from
111       the $Config::Tiny::errstr variable, or using the "errstr()" method.
112

SUPPORT

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

AUTHOR

122       Adam Kennedy <adamk@cpan.org>
123

ACKNOWLEGEMENTS

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

SEE ALSO

129       Config::Simple, Config::General, ali.as
130
132       Copyright 2002 - 2006 Adam Kennedy.
133
134       This program is free software; you can redistribute it and/or modify it
135       under the same terms as Perl itself.
136
137       The full text of the license can be found in the LICENSE file included
138       with this module.
139
140
141
142perl v5.8.8                       2006-09-30                   Config::Tiny(3)
Impressum