Subject: | parsing MySQL like ini files |
Date: | Tue, 25 Mar 2014 12:39:58 +0100 |
To: | bug-Config-Simple [...] rt.cpan.org |
From: | Balazs Pocze <banyek [...] gmail.com> |
Hello,
I am using Config::Parser::Simple for several scripts, and I think
I've found a bug.
In MySQL ini files there is a way to include other configuration with
!include /file/to/include
format, but Config::Parser::Simple module fails when it encounters this.
The error message is the following:
"Something went wrong. No supported configuration file syntax found.
Either the file is of wrong syntax, or there is a bug in
guess_syntax() method. at /usr/share/perl5/Config/Simple.pm line 184,
<FH> line 4."
After investigating the problem, the parser understands that this is
an .ini file, but fails when encounters the "!" at the beginning of
the file.
The solution is easy, just add one more line in the parse_ini_file
sub, and then the parser will skip the "!include" lines, and
everything else will unharmed.
Here is the patch inline, I also attach it.
--- /usr/share/perl5/Config/Simple.pm 2014-03-25 07:25:23.230111302 -0400
+++ Simple.pm 2014-03-25 07:25:44.088839310 -0400
@@ -277,6 +277,7 @@
# skipping comments and empty lines:
$line =~ /^\s*(\n|\#|;)/ and next;
+ $line =~ /^\!/ and next;
$line =~ /\S/ or next;
chomp $line;
--
"Before enlightenment, I chopped wood and carried water. After
enlightenment, I chopped wood and carried water"
Message body is not shown because sender requested not to inline it.