if ( $length ) { print "Expecting $length bytes\n"; while ( length($data) < $length ) { last unless sysread( STDIN, $buf, 16 ); print "Got: $buf\n"; $data .= $buf; } }