for(0..1) { my @ready = $self->{root}{select}->can_read(0); for(@ready) { $self->handle_child_message($self->{root}{childreads}{$_},$_); } } sub handle_child_message { my $self = shift; my $child = shift; my $cr = shift; my $msg = <$cr>; if($msg =~ /^call/) { $self->{root}{busy}{$child} = 1; $self->{root}{busycount}++; $self->{root}{children}{$child}{calls}++; } elsif($msg =~ /^waiting/) { $self->{root}{busycount}-- if delete $self->{root}{busy}{$child}; } }