Muskovitz has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks! im here again because i can't really make a messenger in perl i have a very limited amount of networking in perl i was trying to create a messenger in perl where you can select who you want to chat e.g i want to chat John so i just want to click his name and start chatting. So here's my code i push all the filehandles in 1 array which it turns to group chat. But i don't want group chat but i don't know what to do with this filehandles!

#!/usr/bin/perl use strict; use warnings; use IO::Socket::INET; use threads; use threads::shared; my @clients : shared; @clients=(); my $socket=new IO::Socket::INET( LocalAddr=>'localhost', LocalPort=>7777, Proto=>'tcp', Timeout=>7200, Listen=>7, Reuse=>1 ) || die "$!\n"; while(1){ my $client; $client=$socket->accept; my $peerhost=$client->peerhost; my $peerport=$client->peerport; print "$peerhost:$peerport\n"; my $f_client=fileno $client; push(@clients,$f_client); my $thr=threads->create(\&accept,$client,$peerhost,$f_client); } sub accept{ my ($client1,$peerhost1,$f_client1)=@_; if($client1->connected){ while(<$client1>){ foreach my $fn(@clients){ open(my $fh, ">&=$fn") || die "$!\n"; print $fh "$_"; } } } }