use Tk; use strict; my $mw = MainWindow->new; $mw->configure(-title => 'Verify User',-background =>'blue'); $mw->geometry('+100+300'); my $name = ''; # declare a variable for the value of "name" my $vu_frml = $mw->Frame(-relief=>'groove', -borderwidth => 3, -background =>'blue', )->pack(-side => 'top', -fill => 'x'); my $vu_lb1 = $vu_frml->Label(-text =>'name', -background=>'blue', -foreground=>'white', )->pack(-side=>'left'); # use that "name" variable with this Entry widget: my $vu_enl = $vu_frml->Entry(-width =>9, -textvariable => \$name, -background => white' )->pack(-side=>'left',-pady=>3); $mw->Button( -background=>'blue', -foreground=>'white', -text => 'ok', -command => sub { # use the variable again here: $mw -> Label(-textvariable => \$name, -font => "fixed", )-> pack; }, )->pack(-side => 'top', -fill => 'x'); MainLoop;