You say the perldiver.cgi script outputs good HTML on the command line - but, but, but, when run as a CGI, it absolutely *needs* to output:
before, before, before any other output to the browser. If you do not output that text, then the browser has no flipping clue what data is coming to it, so it will return an error) about premature script headers.
Generically though, "premature script headers" could be any number of problems, only one of which could be missing that Content-type line. To further debug your problem, check out the various documents at Debugging Perl - About.com (but be prepared for tons of popup advertisements).