while(my @ready = $select->can_read) { foreach my $ts (@ready) { if($ts == $sock1) { my $input = <$sock1>; chomp $input; print "sock1: $input\n"; } elsif($ts == $sock2) { my $input = <$sock2>; chomp $input; print "sock2: $input\n"; } } }