if ($pid = open(CHILD,"-|")) { while () { $data .= $_; } print $data; } else { exec ("ls"); }