Ah, see there's always more to it. If you are in a GUI application, you have an event loop. If you have an event loop, you could schedule your timeout or delay with that event loop rather than using sleep, etc. For example, if you're using tk, then look at the bind method (perldoc Tk::bind).