in reply to Perl/Tk freezes while waiting the data to arrive on mysql server

Programs like this one usually need to have at least two threads, since the “main thread” is obligated to respond to messages from the GUI.   Every mouse-click, maybe mouse-pointer moves, notifications to repaint this-or-that, and so-forth, generates a “message,” and the main thread must very-timely respond to every one.   (Basically, this is the main-thread’s only job ...)   Otherwise, the interface will freeze.   Therefore, a second thread must take care of anything that is time-consuming and/or that requires waiting.   The thread can update the interface:   its actions will be properly interlocked with those of the main thread.   Typically, this thread is sent requests to do work, which are posted to it in a thread-safe queue, and it dequeues the requests and carries them out.   The main thread doesn’t wait for them to be completed, but goes about its business of keeping the screen up-to-date.   The two threads are completely asynchronous to one another.

There are lots of existing examples of GUI-based programs (Perl/TK nd otherwise ...) which do “time-consuming things” in this way, so I won’t repeat myself further.   There are also existing frameworks which include at-least the skeleton of the necessary multi-threaded architecture.   So, look around.