in reply to Premature end of script headers.

The first think you should do is get the error message from the error log file.

The problem is that you never import header. Replace
use CGI;
with
use CGI qw( :standard );

Also,
#!/usr/local/perl -w
should probably be
#!/usr/bin/perl -w

I'm surprised by your claim that it works from the prompt. It shouldn't, and it doesn't on my machine.

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

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.