I want to use a number of .ini files to store sets of values to pick up later, when I re-run the script (after a reboot, e.g.). I am trying to write my code such that it will first check to see if the specific .ini file exists, and if so, read in the values, but if not, then create it (the script will subsequently proceed to store values in it).
if (-f '/path/to/file.ini') { # if file exists # read file into object my $ini = Config::IniFiles->new(-file => '/path/to/file.ini', -nomultiline => 1, -fallback => 'parameters', -commentchar => ';' );} else { # create first instance of ini file WriteConfig('/path/to/file.ini');}
Obviously I don't understand how to use Config::InFiles
because it keeps failing on WriteConfig('/path/to/file.ini');
.
Can I create a file with this module, or do I have to do it another way?