Thanks for the reply. In the production code I do use strict & warnings. Should have in the test program too. Oops. AH! Excellent! I am clearing the whole hash. Duh! Thanks so much. And thanks for the tip. Big thanks!! ;-) For completeness, the new code works.
use Tk; use strict; use warnings; require Tk::Entry; require Tk::Button; my $mw = MainWindow->new(); my %work = ( "VM-1" => "da923", "VM-2" => "dz427"); main_display(\%work); MainLoop; # ----------------------------------------------------- sub main_display { my $ref_hash = shift(@_); my $lab1 = $mw->Label(-textvariable => \$ref_hash->{'VM-1'}, -relief => 'sunken', -width => 10, )->pack(); my $lab2 = $mw->Label(-textvariable => \$ref_hash->{'VM-2'}, -relief => 'sunken', -width => 10, )->pack(); my $but = $mw->Button(-text=>'clear', -command=> [sub{ $ref_hash->{'VM-1'} = " "; $ref_hash->{'VM-2'} = " "; $mw -> update; }] )->pack(); }
In reply to Re^6: Perl Tk label references
by thimes
in thread Perl Tk label references
by thimes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |