my $pid = open (NMAKE, '-|', "nmake .... 2>&1"); if (!defined $pid) { warn "Couldn't start nmake"; } while () { print STDERR $_; print STDOUT $_; } close (NMAKE); my $status = $?; if ($status) { # ... }