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 :)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.