in reply to Re^2: Perl CGI ability to start linux services
in thread Perl CGI ability to start linux services

If an error occurred, its code will be found in $?, not $val. Moreover, the exit status will be found in the high byte:
$? >> 8
As an aside, if you are running this on a Red Hat derivative, this could be an selinux issue. See thread "Premature end of script headers more annoying than usual . . ." for suggestions on determining if selinux is the source of the problem.