I'm not sure what Asterisk::AMI does, but it seems to be blocking your Tk eventloop. You may need to the Asterisk tasks in a thread, then use Tk::fileevent to read the socket. See Re: Perl Tk and Threads and google for "perl tk threads" for other examples.