use threads; use threads::shared; use Win32::SerialPort; use Net::FTP; my $sp = new Wi3n32::SerialPort( ... ); ... my $count = $sp-write( $out ); my $done :shared = 0; my $t = async{ my $in; until( $done ) { my( $count, $byte ) = $sp->read( 1 ); warn "Read error" and next unless $count = 1; $in .= $byte; } return $in; }; my $ftp = new Net::FTP( ... ); $ftp->get( 'theFile' ); $ftp->done; $done = 1; my $input = $t->join;