All pastes #335160 Raw Edit

Stuff

public text v1 · immutable
·published 2007-02-01 04:18 UTC
rendered paste body
	while ( $s->count() > 0 ) {
		while (my @ready = $s->can_read()) { 
			foreach my $fh ( @ready ) {
				my $buff;
		       	 	my $res = sysread($fh, $buff, 1024);
				if ($res > 0) { 
					my $host = $results{$fh};
				   	$results{$host} .= $buff;
				}
				elsif (defined $res) { 
					if ( $res == 0) {
						delete $results{$fh};
						$s->remove($fh);
#						print "Closing $fh\n";
						close $fh;
					}
				}
				else { 
#					$res is undef, so tell our user about the error
					print "Something broke! : $!\n";
				}
				
			}
		}
	}