in reply to Premature end of script headers.

Change the following line:

use CGI;

...to...

use CGI qw/:standard/;

The problem is that the header isn't getting printed. It's not getting printed because you didn't ask it to be imported. The qw/:standard/; does that for you.

If you check the error logs you would also see (in the error logs) why the script failed. Strictures will complain:

Unquoted string "header" may clash with future reserved word at mytest +.pl line 8. Name "main::header" used only once: possible typo at mytest.pl line 8. print() on unopened filehandle header at mytest.pl line 8.

Dave