http://www.perlmonks.org?node_id=558820


in reply to Premature end of script headers error

According to your error messages, I suspect the exec bit is not turned on, do: chmod +x test.pl (or whatever is required so the apache User has permissions to run it.)

I would also uncomment CGI::Carp until things work, just to ensure that test.pl is compilable.