NAME Config::Tiny::Ordered - Read ordered .ini style files with as little code as possible SYNOPSIS # In your configuration file rootproperty=blah [section] reg_exp_1=High Priority reg_exp_2=Low Priority three= four Foo =Bar empty= # In your program use Config::Tiny::Ordered; # Create a config my $Config = Config::Tiny::Ordered->new(); # Open the config $Config = Config::Tiny::Ordered->read( 'file.conf' ); # Reading properties my $rootproperty = $Config->{_}->{rootproperty}; my $section = $Config->{section}; # An arrayref of hashrefs, my $re0 = $$section[0]{'key'}; # where the format is: my $re1 = $$section[0]{'value'}; # [{key => ..., value => ...}, my $re2 = $$section[1]{'value'}; # {key => ..., value => ...}, my $Foo = $$section[3]{'value'}; # ...]. DESCRIPTION "Config::Tiny::Ordered" is a perl class to read .ini style configuration files with as little code as possible, reducing load time and memory overhead. Most of the time it is accepted that Perl applications use a lot of memory and modules. The "Config::Tiny" family of modules is specifically intended to provide an ultralight alternative to the standard modules. 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::Tiny, Config::Simple, Config::General or one of the many other "Config::*" modules. To rephrase, Config::Tiny::Ordered does not preserve your comments or whitespace. This module differs from "Config::Tiny" in that here the data within a section is stored in memory in the same order as it appears in the input file or string. "Config::Tiny::Ordered" does this by storing the keys and values in an arrayref rather than, as most config modules do, in a hashref. This arrayref consists of an ordered set of hashrefs, and these hashrefs use the keys 'key' and 'value'. So, in memory, the data in the synopsis, for the section called 'section', looks like: [ {key => 'reg_exp_1', value => 'High Priority'}, {key => 'reg_exp_2', vlaue => 'Low Priority'}, etc ] This means the config file can be used in situations such as with business rules which must be applied in a specific order. CONFIGURATION FILE SYNTAX Files are the same format as for windows .ini files. For example: [section] var1=value1 var2=value2 If a property is outside of a section at the beginning of a file, it will be assigned to the "root section", available at "$Config->{_}". Lines starting with '#' or ';' are considered comments and ignored, as are blank lines. METHODS new The constructor "new" creates and returns an empty "Config::Tiny::Ordered" object. read $filename The "read" constructor reads a config file, and returns a new "Config::Tiny::Ordered" object containing the properties in the file. Returns the object on success, or "undef" on error. When "read" fails, "Config::Tiny::Ordered" sets an error message internally you can recover via ">. Although in some cases a failed "read" will also set the operating system error variable $!, not all errors do and you should not rely on using the $! variable. read_string $string; The "read_string" method takes as argument the contents of a config file as a string and returns the "Config::Tiny::Ordered" object for it. write $filename The "write" method generates the file content for the properties, and writes it to disk to the filename specified. Returns true on success or "undef" on error. write_string Generates the file content for the object and returns it as a string. errstr When an error occurs, you can retrieve the error message either from the $Config::Tiny::Ordered::errstr variable, or using the "errstr()" method. SUPPORT Bugs should be reported via the CPAN bug tracker at For other issues, or commercial enhancement or support, contact the author. AUTHORS Adam Kennedy , Ron Savage ACKNOWLEGEMENTS This module is 99% the same as Config::Tiny by Adam Kennedy. Ron Savage made some tiny changes to suppport the preservation of key order. The test suite was likewise adapted. SEE ALSO Config::Tiny, Config::Simple, Config::General, ali.as Copyright Copyright 2002 - 2007 Adam Kennedy. Australian copyright (c) 2009, Ron Savage. All rights reserved. All Programs of Ron's are 'OSI Certified Open Source Software'; you can redistribute them and/or modify them under the terms of the Artistic or the GPL licences, copies of which is available at: http://www.opensource.org/licenses/index.html