Not pretty, and perhaps there are better ways, but this may get you
started anyway:
#!/usr/bin/perl -w
use strict;
use IO::Pty;
my $pty = new IO::Pty;
my $slave = $pty->slave();
my $pid = fork();
die "Couldn't fork: $!" unless defined $pid;
if($pid){ # dup STDOUT to Pty and run external program:
$pty->close_slave();
open(STDOUT, ">&",$pty)||die $!;
system "perl blackbox.pl";
print "\cD"; # send ^d to end
} else { # this is your monitoring process
$pty->make_slave_controlling_terminal();
print "*$_" while <$slave>;
exit;
}
__END__
Works for me on Linux.