in reply to Re^3: Perl Tk label references
in thread Perl Tk label references

You created references to a couple of hash keys when you made the labels. If you later assign the $ref_hash variable to point to a "brand new" empty hash, that won't affect the label text locations. As far as Perl is concerned, those memory locations are still in use and unchanged. You could just change the value of the label keys to "" as shown below.
use Tk; use strict; use warnings; use Data::Dumper; 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(); }