my $bit_in = ''; my $r_bit; vec($bit_in, fileno($f), 1) = 1; while(1) { select($r_bit = $bit_in, undef, undef, tick_len); # if select said there was data... if(vec($r_bit,fileno($f),1)) { my $in; # connection lost if sysread returns undef return unless $f->sysread($in, 1); # otherwise, it's good data $str .= $in; last if $in eq "\n"; } }