foreach $handle1 (@read_from) {
$buf = <$new_sock>;
if($buf){ print $buf; }
}
####
foreach my $handle1 (@read_from) {
my $buf = '';
my $rv = sysread($handle1, $buf, 64*1024, length($buf));
# Handle error if !defined($rv)
# Handle eof if !$rv
print $buf; # Whatever we got, including partial lines
}
####
foreach my $handle1 (@read_from) {
our $buf; local *buf = \( $buf{fileno($handle1)} ); # alias
$buf = '' if !defined($buf);
my $rv = sysread($handle1, $buf, 64*1024, length($buf));
# Handle error if !defined($rv)
# Handle eof if !$rv
while ($buf =~ s/^(.*\n)//) {
print $1; # Full line at a time
}
}