//time out is from the Time::Out module. my $ret = timeout 5 => sub { my $r = `perl /ExecScript.pl '$code' "$arg" &2>1`; return $r; } ; ########### # ExecScript.pl ###### if($ARGV[0]) { my $code = $ARGV[0]; my $arg = $ARGV[1]; open(my $fh,'|-', 'perl', '-', $arg); print $fh $code; close($fh); }