NAME
Config::Abstract - Perl extension for abstracting configuration files
SYNOPSIS
use Config::Abstract;
my $ini = new Config::Abstract('test.ini');
DESCRIPTION
Config::Abstract is the base class for a number of other classes
created to facilitate use and handling of a variety of different
EXAMPLES
We assume the content of the file 'test.ini' to be:
[myentry]
;comment
thisssetting = that
thatsetting=this
;end of ini
use Config::Abstract;
my $settingsfile = 'test.ini';
my $settings = new Config::Abstract($settingsfile);
# Get all settings
my %allsettings = $settings->get_all_settings;
# Get a subsection (called an entry here, but it's
# whatever's beneath a [section] header)
my %entry = $settings->get_entry('myentry');
# Get a specific setting from an entry
my $value = $settings->get_entry_setting('myentry',
'thissetting');
# Get a specific setting from an entry, giving a default
# to fall back on
my value = $settings->get_entry_setting('myentry',
'missingsetting',
'defaultvalue');
We can also make use of subentries, with a ini file like
this:
[book]
title=A book of chapters
author=Me, Myself and Irene
[book::chapter1]
title=The First Chapter, ever
file=book/chapter1.txt
[book::chapter2]
title=The Next Chapter, after the First Chapter, ever
file=book/chapter2.txt
# btw, you can use unix style comments, too...
;end of ini
use Config::Abstract;
my $settingsfile = 'test2.ini';
my $ini = new Config::Abstract($Settingsfile);
my %book = $ini->get_entry('book');
my %chap1 = $ini->get_entry_setting('book','chapter1');
my $chap1title = $chapter1{'title'};
# Want to see the inifile?
# If you can live without comments and blank lines ;),
# try this:
print("My inifile looks like this:\n$ini\nCool, huh?\n");
METHODS
- get_all_settings
-
Returns a hash of all settings found in the processed file
- get_entry ENTRYNAME
-
Returns a hash of the settings within the entry ENTRYNAME
- get_entry_setting ENTRYNAME,SETTINGNAME [,DEFAULTVALUE]
-
Returns the value corresponding to ENTRYNAME,SETTINGSNAME. If the value isn't set it returns undef or, optionally, the DEFAULTVALUE
- set_all_settings SETTINGSHASH
-
Fill settings with data from SETTINGSHASH
- set_entry ENTRYNAME,ENTRYHASH
-
Fill the entry ENTRYNAME with data from ENTRYHASH
- set_entry_setting ENTRYNAME,SETTINGNAME,VALUE
-
Set the setting ENTRYNAME,SETTINGSNAME to VALUE
UTILITY METHODS
COPYRIGHT
Copyright 2001 Eddie Olsson.
This library is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
AUTHOR
Eddie Olsson <ewt@avajadi.org>
SEE ALSO
perl.
4 POD Errors
The following errors were encountered while parsing the POD:
- Around line 294:
'=item' outside of any '=over'
- Around line 318:
You forgot a '=back' before '=head2'
- Around line 320:
'=item' outside of any '=over'
- Around line 324:
You forgot a '=back' before '=head1'