Unix/Linux Go Back    

CentOS 7.0 - man page for config::tiny (centos section 3)

Linux & Unix Commands - Search Man Pages
Man Page or Keyword Search:   man
Select Man Page Set:       apropos Keyword Search (sections above)

Config::Tiny(3) 	       User Contributed Perl Documentation		  Config::Tiny(3)

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

	   # In your configuration file

	   three= four
	   Foo =Bar

	   # In your program
	   use Config::Tiny;

	   # Create a config
	   my $Config = Config::Tiny->new;

	   # Open the config
	   $Config = Config::Tiny->read( 'file.conf' );

	   # Reading properties
	   my $rootproperty = $Config->{_}->{rootproperty};
	   my $one = $Config->{section}->{one};
	   my $Foo = $Config->{section}->{Foo};

	   # Changing data
	   $Config->{newsection} = { this => 'that' }; # Add a section
	   $Config->{section}->{Foo} = 'Not Bar!';     # Change a value
	   delete $Config->{_}; 		       # Delete a value or section

	   # Save a config
	   $Config->write( 'file.conf' );

       "Config::Tiny" is a perl class to read and write .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 "::Tiny" family of
       modules is specifically intended to provide an ultralight alternative to the standard

       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

       Files are the same format as for windows .ini files. For example:


       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.

       When writing back to the config file, all comments, custom whitespace, and the ordering of
       your config file elements is discarded. If you need to keep the human elements of a config
       when writing back, upgrade to something better, this module is not for you.

       The constructor "new" creates and returns an empty "Config::Tiny" object.

   read $filename
       The "read" constructor reads a config file, and returns a new "Config::Tiny" object
       containing the properties in the file.

       Returns the object on success, or "undef" on error.

       When "read" fails, "Config::Tiny" sets an error message internally you can recover via
       "Config::Tiny->errstr". 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 $!

   read_string $string;
       The "read_string" method takes as argument the contents of a config file as a string and
       returns the "Config::Tiny" 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.

       Generates the file content for the object and returns it as a string.

       When an error occurs, you can retrieve the error message either from the
       $Config::Tiny::errstr variable, or using the "errstr()" method.

   Unsupported Section Headers
       Some edge cases in section headers are not support, and additionally may not be detected
       when writing the config file.

       Specifically, section headers with leading whitespace, trailing whitespace, or newlines
       anywhere in the section header, will not be written correctly to the file and may cause
       file corruption.

       Bugs should be reported via the CPAN bug tracker at


       For other issues, or commercial enhancement or support, contact the author.

       Adam Kennedy <adamk@cpan.org>

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

       Config::Simple, Config::General, ali.as

       Copyright 2002 - 2011 Adam Kennedy.

       This program is free software; you can redistribute it and/or modify it under the same
       terms as Perl itself.

       The full text of the license can be found in the LICENSE file included with this module.

perl v5.16.3				    2011-03-24				  Config::Tiny(3)
Unix & Linux Commands & Man Pages : ©2000 - 2018 Unix and Linux Forums

All times are GMT -4. The time now is 07:44 AM.