After Googling, Super Searching and following this quiet thread, the "answer" struck me after some heavy drinking (who said alcohol was bad for the brain again? ;)
My script checks whether there is a config file. If there's none, it will create one. The subroutine that creates it, used to have static, non-variable default values. So for example:
open (CONF, ">$conffile");
print CONF<<EOF
option1 = default text
option2 = other text
EOF
;
close CONF;
In stead of this approach, I now give the variables a default value during defining them:
$config->define('option1', { DEFAULT => "default text" } );
$config->define('option1', { DEFAULT => "other text" } );
Then, of course, I change the creation of the file to:
open (CONF, ">$conffile");
print CONF "option1 = ", $config->option1(), "\n";
print CONF "option2 = ", $config->option2(), "\n";
close CONF;
This way, I can change the variables through my Tk GUI and recreate the file (by calling the subroutine responsible):
$config->option1('Specified through GUI');
&CreateConfigFile;
It might not be the best solution, but it works rather simple and well. But since we're talking Perl here, there must be other solutions and I'd love to hear them :)
|