#!/usr/bin/perl defined ($pid = open $fh, "-|") or warn $! and last; if ($pid) { # Parent while (<$fh>) { print "OUTPUT: $_"; } } else { # Child exec("/bin/ls"); }