my ($done, $rb, $byte) = $port->read_done(0); $port->read_bg(1) if ($done); if ($rb > 0) { print $fh "$byte\n"; }