#!/usr/bin/perl use Tk; use Tk::Listbox; use IO::Socket::INET; use strict; use warnings; my $top = MainWindow->new; my $f = $top->Frame->pack; my $lb = $f->Listbox()->pack; my $socket = IO::Socket::INET->new(PeerAddr => 'localhost', PeerPort => 8889, Proto=>'tcp') or die "Cannot connect: $!\n"; $top->fileevent($socket, readable => sub { chomp(my $line = <$socket>); print STDERR "$line"; $lb->insert('end',":$line"); # $lb->insert('end',$line) or die; }); MainLoop;