I am trying to develop a config file manager. I need, initially, to be able to read and display the current keyword=value records, edit the values, add new records and delete old records. All works fine except the delete because I don't know, at the time the delete button is pressed, the name of the particular widget to remove or the keyword to delete from my hash. My code looks like this but clearly won't work because "$_" is not static and has changed (become undefined) by the time I try to use the button.
sub cfgRuntime {
if (!%runtime) {
loadConfig();
}
$workframe -> Label(-text=>"Folder Separator") -> grid(-row=>1, -c
+olumn=>1, -rowspan=>2);
$workframe -> Radiobutton(-text=>"Windows", -value=>"\\", -variabl
+e=>\$runtime{'fsep'}) -> grid(-row=>1, -column=>2, -sticky=>"w");
$workframe -> Radiobutton(-text=>"Unix", -value=>"/", -variable=>\
+$runtime{'fsep'}) -> grid(-row=>2, -column=>2, -sticky=>"w");
$workframe -> Button(-text => "Save these values", -command=>[\&up
+dGUIInput, "runtime", "save"])
-> grid(-row=>1, -column=>3, -sticky=>"e");
$workframe -> Button(-text => "Discard these values", -command=>[\
+&updGUIInput, "runtime", "discard"])
-> grid(-row=>2, -column=>3, -sticky=>"e");
$row = 3;
for (keys %runtime) {
if ($_ eq "fsep") {next}
$workframe -> Label(-text=>$_) -> grid(-row=>$row, -column=>1)
+;
$workframe -> Entry(-width=>100, -textvariable=>\$runtime{$_})
+ -> grid(-row=>$row, -column=>2);
$workframe -> Button(-text=>"Delete entry", -command=>
sub {
delete $runtime{$_};
}
)
-> grid(-row=>$row, -column=>3);
$rowsin = $row;
$row++;
}
$btnNew = $workframe -> Button(-text=>"New variable",
-command=>\&newVar
) -> grid(-row=>$row, -column=>1, -sticky=>"w");
}
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.