use warnings; use Tk; sub one; my $main = MainWindow->new; my $button; my $button2; my $label1; $label1 = $main->Text ( '-width'=>'50')->pack; $button = $main->Button( -text=>'next', -command=>\&one)->pack; $button2 = $main->Button( -text=>'quit', -command=>sub{exit;})->pack; our $foo = "0"; MainLoop; sub one { my $talk="Hey, that was click $foo\n"; $foo++; $label1 -> insert('1.0',$talk); }