http://www.perlmonks.org?node_id=985349


in reply to Re^2: Stumped with select->can_read (buffered)
in thread Stumped with select->can_read

It's best to use sysread, but you will have to figure out a way to detect line endings. Maybe after concating the sysread data into a temp buffer then pull off lines with a regex or split. Read perldoc -f sysread. It will read as much as it can in a non-blocking manner. This will try to read in 1024 byte chunks, but will read less if that is all that is there.
while(@ready = $sel->can_read) { foreach my $fh(@ready) { my $line = ""; my $buf = ""; # while(read($fh, $buf, 1024)) while( my $bytes_read = sysread( $fh, $buf, 1024 ) > 0 ) ) { print "$bytes_read\n"; { $line .= $buf; } } }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh