use strict; use warnings; use IO::Socket::INET; use IO::Select; my $server = IO::Socket::INET->new(    LocalPort => 2005,    type => SOCK_STREAM,    Reuse => 1,    Listen => 10 ) or die "Server läuft nicht: $@\n"; my $select = IO::Select->new($server); my %users = (); while(my @readable = $select->can_read) {     foreach my $socket (@readable) {         if($socket == $server) {             my ($client, $ip) = $socket->accept;             $select->add($client);             my ($port, $iaddr) = unpack_sockaddr_in($ip);             $iaddr = inet_ntoa($iaddr);            $users{rand(100)} = $iaddr;             print "New Client connected: $iaddr\n";             $client->print("Welcome\n");         } else {             my $line = $socket->getline;             if(defined $line) {                  $line =~ s!\r?\n$!!g;                  if(lc($line) eq "quit") {                      print "Client quits\n";                      delete_socket($select, $socket);                  } else {                      print "Client says: [$line]\n";                      $socket->print("$line\n");                  }             } else {                  print "Connection closed by client\n";                  delete_socket($select, $socket);             }         }     } } sub delete_socket {   my ($sel, $sock) = @_;   $sel->remove($sock);   $sock->close; }