use strict; use Tk; use Threads; my ($mw,$sent_recvd_listbox,$server_list_listbox); threads->new(\&update_thread)->detach; create_tk_window(); $mw->MainLoop; sub update_thread { print "update_thread called...\n"; while(1) { if(defined($server_list_listbox)) { # This never gets executed because the objects from # the tk module are out of scope ?????? $server_list_listbox->insert('end',"Some string data"); }else{ print "Couldn't insert any data cause this thread can't see the tk objects !?\n"; } sleep 1; } exit(); } sub create_tk_window { $mw=MainWindow->new ( -background=>'#dedede', -foreground=>'yellow', -title=>"FingerLick" ); $mw->geometry("802x618"); $mw->minsize(802,618); $mw->maxsize(802,618); $sent_recvd_listbox=$mw->Listbox ( -height=>1, -width=>60, -background=>'black', -foreground=>'yellow' )->pack(-side=>'bottom',-anchor=>'s',-pady=>2); $server_list_listbox=$mw->Scrolled ( "Listbox", -height=>20, -width=>60, -background=>'white', -foreground=>'black', -scrollbars=>'se', )->pack(); }