Config::Extend::MySQL - Read MySQL configuration file
Version 0.01
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 ...
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.
Config::
Currently supported modules are Config::IniFiles, Config::INI::Reader and Config::Tiny.
Config::IniFiles
Config::INI::Reader
Config::Tiny
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.
.INI
!include
!includedir
Hence this module which simply slurps all the files, recursing though the !include and !includedir directives and 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.
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 file
from
using - the module name to use as backend for parsing the configuration file
using
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
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.
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.
Missing required argument '%s'
(E) You forgot to supply a mandatory argument.
The different supported modules don't parse .INI files exactly the same ways, and have different behaviours:
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.
Sébastien Aperghis-Tramoni, <sebastien at aperghis.net>
<sebastien at aperghis.net>
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/NoAuth/ReportBug.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.
bug-config-extend-mysql at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Config::MySQL
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Config-MySQL
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Config-MySQL
CPAN Ratings
http://cpanratings.perl.org/d/Config-MySQL
Search CPAN
http://search.cpan.org/dist/Config-MySQL
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.
To install Config::Extend::MySQL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Config::Extend::MySQL
CPAN shell
perl -MCPAN -e shell install Config::Extend::MySQL
For more information on module installation, please visit the detailed CPAN module installation guide.