use IO::Pipe; ... foreach $tapeDevice (@tapeDevices) { $pipeFH = IO::Pipe->new(); ... if($pid = fork()) { # This is the parent. $pipeFH->reader(); push @pipes, $pipeFH; ... } elsif(defined $pid) { # This is the child. $pipeFH->writer(); # Do lots of stuff writing to tape ... $pipeFH->print("some message or other"); ... } else { # Fork failed for some reason. die "fork: $!\n"; } } # We have now forked a child for each tape device so # wait for our children to finish. Print exit status. while((my $returnPID = wait()) != -1) { print "Child $returnPID returned status ", $? >> 8, "\n"; } # All children have returned, get messages. foreach $pipe (@pipes) { while(defined($_ = $pipe->getline())) { # Do something ... } }