my $written = $ssl->write(substr($cur_buff, $cur_count)); if($written <= 0){ unless($! eq "Resource temporarily unavailable"){ ## An error has occurred - recovery code goes here } return; } $cur_count += $written; if($cur_count == length($cur_buff)){ $cur_count = 0; $cur_buff = undef; ### We have emptied the current buffer ### Here is where code specific to select dispatcher ### must determine whether we have written all the data... }