NAME
Config::Extend::MySQL - Extend your favourite .INI parser module to read MySQL configuration file
VERSION
Version 0.05
SYNOPSIS
use Config::Extend::MySQL;
# read MySQL config using Config::IniFiles
my $config = Config::Extend::MySQL->new({ from => $file, using => "Config::IniFiles" });
# read MySQL config using Config::Tiny
my $config = Config::Extend::MySQL->new({ from => $file, using => "Config::Tiny" });
# use the resulting object as you usually do
...
DESCRIPTION
This module extends other Config::
modules so they can read MySQL configuration files. It works by slurping and preprocessing the files before letting your favourite Config::
module parse the result.
Currently supported modules are Config::IniFiles
, Config::INI::Reader
and Config::Tiny
.
Rationale
This module was written out of a need of reading MySQL configuration files from random machines. At first, the author thought they were just classical .INI
files, but soon discovered that they include additional features like !include
and !includedir
, and bare boolean options, which without surprise make most common modules choke or die.
Hence this module which simply slurps all the files, recursing though the !include
and !includedir
directives, inlining their content in memory, and transforms the bare boolean options into explicitly assigned options.
As to why this module extends other modules instead of being on its own, it's because the author was too lazy to think of yet another API and preferred to use the modules he already know. And given he use several of them, depending on the context, it was just as easy to avoid being too thighly coupled to a particular module.
METHODS
new()
Create and return an object
Usage
my $config = Config::Extend::MySQL->new({ from => $file, using => $module });
Options
from
- the path to the main MySQL configuration fileusing
- the module name to use as backend for parsing the configuration file
Examples
# read MySQL config using Config::IniFiles
my $config = Config::Extend::MySQL->new({ from => $file, using => "Config::IniFiles" });
# $config ISA Config::Extend::MySQL, ISA Config::IniFiles
# read MySQL config using Config::Tiny
my $config = Config::Extend::MySQL->new({ from => $file, using => "Config::Tiny" });
# $config ISA Config::Extend::MySQL, ISA Config::Tiny
DIAGNOSTICS
Arguments must be given as a hash reference
-
(E) As the message says, the arguments must be given to the function or method as a hash reference.
Backend module failed to parse '%s'
-
(F) The backend module was unable to parse the given file. See "CAVEATS" for some hints.
Can't load module %s: %s
-
(F) The backend module could not be loaded.
Can't read in-memory buffer: %s
-
(F) This should not happen.
Empty argument '%s'
-
(E) The given argument was empty, but a value is required.
File '%s' is empty
-
(W) The file is empty.
Missing required argument '%s'
-
(E) You forgot to supply a mandatory argument.
No such file '%s'"
-
(F) The given path does not point to an existing file.
CAVEATS
The different supported modules don't parse .INI
files exactly the same ways, and have different behaviours:
Config::IniFiles
doesn't want to create an object from an empty file.Config::INI::Reader
by default doesn't allow the pound sign (#
) for beginning comments.when assigning the same option twice,
Config::Tiny
replaces the old value with the new one,Config::IniFiles
appends it with a newline.
And probably many more.
Also note that in order to keep the code simple, this module wants Perl 5.6 or newer. However, a patch to make it work on Perl 5.5.3 is included in the distribution (patches/patch-for-perl5.5.diff).
SEE ALSO
AUTHOR
Sébastien Aperghis-Tramoni, <sebastien at aperghis.net>
BUGS
Please report any bugs or feature requests to bug-config-extend-mysql at rt.cpan.org
, or through the web interface at http://rt.cpan.org/Dist/Display.html?Queue=Config-Extend-MySQL. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Config::Extend::MySQL
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/Dist/Display.html?Queue=Config-Extend-MySQL
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
COPYRIGHT & LICENSE
Copyright 2008 Sébastien Aperghis-Tramoni, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.