1Config::Extend::MySQL(3U)ser Contributed Perl DocumentatiCoonnfig::Extend::MySQL(3)
2
3
4
6 Config::Extend::MySQL - Extend your favourite .INI parser module to
7 read MySQL configuration file
8
10 Version 0.04
11
13 use Config::Extend::MySQL;
14
15 # read MySQL config using Config::IniFiles
16 my $config = Config::Extend::MySQL->new({ from => $file, using => "Config::IniFiles" });
17
18 # read MySQL config using Config::Tiny
19 my $config = Config::Extend::MySQL->new({ from => $file, using => "Config::Tiny" });
20
21 # use the resulting object as you usually do
22 ...
23
25 This module extends other "Config::" modules so they can read MySQL
26 configuration files. It works by slurping and preprocessing the files
27 before letting your favourite "Config::" module parse the result.
28
29 Currently supported modules are "Config::IniFiles",
30 "Config::INI::Reader" and "Config::Tiny".
31
32 Rationale
33 This module was written out of a need of reading MySQL configuration
34 files from random machines. At first, the author thought they were just
35 classical ".INI" files, but soon discovered that they include
36 additional features like "!include" and "!includedir", and bare boolean
37 options, which without surprise make most common modules choke or die.
38
39 Hence this module which simply slurps all the files, recursing though
40 the "!include" and "!includedir" directives, inlining their content in
41 memory, and transforms the bare boolean options into explicitly
42 assigned options.
43
44 As to why this module extends other modules instead of being on its
45 own, it's because the author was too lazy to think of yet another API
46 and preferred to use the modules he already know. And given he use
47 several of them, depending on the context, it was just as easy to avoid
48 being too thighly coupled to a particular module.
49
51 new()
52 Create and return an object
53
54 Usage
55
56 my $config = Config::Extend::MySQL->new({ from => $file, using => $module });
57
58 Options
59
60 · "from" - the path to the main MySQL configuration file
61
62 · "using" - the module name to use as backend for parsing the
63 configuration file
64
65 Examples
66
67 # read MySQL config using Config::IniFiles
68 my $config = Config::Extend::MySQL->new({ from => $file, using => "Config::IniFiles" });
69 # $config ISA Config::Extend::MySQL, ISA Config::IniFiles
70
71 # read MySQL config using Config::Tiny
72 my $config = Config::Extend::MySQL->new({ from => $file, using => "Config::Tiny" });
73 # $config ISA Config::Extend::MySQL, ISA Config::Tiny
74
76 "Arguments must be given as a hash reference"
77 (E) As the message says, the arguments must be given to the
78 function or method as a hash reference.
79
80 "Backend module failed to parse '%s'"
81 (F) The backend module was unable to parse the given file. See
82 "CAVEATS" for some hints.
83
84 "Can't load module %s: %s"
85 (F) The backend module could not be loaded.
86
87 "Can't read in-memory buffer: %s"
88 (F) This should not happen.
89
90 "Empty argument '%s'"
91 (E) The given argument was empty, but a value is required.
92
93 "File '%s' is empty"
94 (W) The file is empty.
95
96 "Missing required argument '%s'"
97 (E) You forgot to supply a mandatory argument.
98
99 "No such file '%s'""
100 (F) The given path does not point to an existing file.
101
103 The different supported modules don't parse ".INI" files exactly the
104 same ways, and have different behaviours:
105
106 · "Config::IniFiles" doesn't want to create
107
108 · "Config::INI::Reader" by default doesn't allow the pound sign ("#")
109 for beginning comments.
110
111 · when assigning the same option twice, "Config::Tiny" replaces the
112 old value with the new one, "Config::IniFiles" appends it with a
113 newline.
114
115 And probably many more.
116
117 Also note that in order to keep the code simple, this module wants Perl
118 5.6 or newer. However, a patch to make it work on Perl 5.5.3 is
119 included in the distribution (patches/patch-for-perl5.5.diff).
120
122 Config::IniFiles
123
124 Config::INI::Reader
125
126 Config::Tiny
127
129 Sebastien Aperghis-Tramoni, "<sebastien at aperghis.net>"
130
132 Please report any bugs or feature requests to "bug-config-extend-mysql
133 at rt.cpan.org", or through the web interface at
134 http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Config-Extend-MySQL
135 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Config-Extend-MySQL>.
136 I will be notified, and then you'll automatically be notified of
137 progress on your bug as I make changes.
138
140 You can find documentation for this module with the perldoc command.
141
142 perldoc Config::Extend::MySQL
143
144 You can also look for information at:
145
146 · RT: CPAN's request tracker
147
148 http://rt.cpan.org/NoAuth/Bugs.html?Dist=Config-Extend-MySQL
149 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Config-Extend-MySQL>
150
151 · AnnoCPAN: Annotated CPAN documentation
152
153 http://annocpan.org/dist/Config-Extend-MySQL
154 <http://annocpan.org/dist/Config-Extend-MySQL>
155
156 · CPAN Ratings
157
158 http://cpanratings.perl.org/d/Config-Extend-MySQL
159 <http://cpanratings.perl.org/d/Config-Extend-MySQL>
160
161 · Search CPAN
162
163 http://search.cpan.org/dist/Config-Extend-MySQL
164 <http://search.cpan.org/dist/Config-Extend-MySQL>
165
167 Copyright 2008 Sebastien Aperghis-Tramoni, all rights reserved.
168
169 This program is free software; you can redistribute it and/or modify it
170 under the same terms as Perl itself.
171
172
173
174perl v5.12.0 2010-04-30 Config::Extend::MySQL(3)