in reply to Adding the output of tailf -f filename to Tk widget (scrolled)

When Perl goes to close the $H handle, it will wait for the running command to finish. Because 'tail -f' never ends, it waits forever. I'd suggest using File::Tail here, but you could also kill the tail yourself. The call to open will return a PID that you can kill when MainLoop is finished.

my $tail_pid = open($H,"tail -f -n 50 z.txt |") or die $!; # etc. MainLoop; kill 9, $tail_pid;