Search code examples
perlperl-module

Using Config::Simple to read MySQL config file with keys without values


I try to configure my mySql config file with perl. I use config::simple for doing this. my code is:

#!/bin/perl
use Config::Simple;

$cfg = new Config::Simple('/etc/mysql/my.cnf');
$cfg->param('bind-address', '192.168.1.11');
$cfg->save();

the problem is that I get an error when a row only has a key and not an value to it. How do I fix this problem?


Solution

  • To extend simbabque's comment I would suggest using Config::MySQL to deal with MySQL config files.

    Config::MySQL extends Config::INI to support reading and writing MySQL-style configuration files. Although deceptively similar to standard .INI files, they can include bare boolean options with no value assignment and additional features like !include and !includedir.