in reply to STDOUT qustion

well if the stdout is something you can,t live without. one way to overcome this problem is piping the stdout from p2 to p1 and then printing it directly to screen like:
open (STDIN,"perl p2.pl|") || die "$!"; while(<STDIN>){ print $_; }
or if it is something small that p2 produces you can capture it with
my $capture = qx($Cmd); print $capture . "\n";
and print it