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");
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.