I haven't seen enough code or error message text to be sure, but I think one or more of these things may help (as they tend to do for CGI errors with code 500):
- use CGI::Carp qw( fatalsToBRowser );
- $| = 1; print "Content-type: text/html\n\n";
- $| = 1; print "Content-type: application/pdf\n\n"; # if you're sending a PDF directly to the browser
- check your log file to see what's said there
- run the program from the command line on the server (even if that means a CGI wrapper program that opens it with system()) and see what error gets reported
- move your Content-type header to an earlier spot in your program
- make sure your shebang line isn't still set up for Windows once you put the program on the Linux server. That's one of the most frustrating things one can overlook, and I speak from experience.
A 500 error means that the server can't serve the request because something went wrong with the program being run or with the web server's configuration. Typically with Apache and Perl, it means you forgot to print the Content-type header or that there's an error in the program which aborts before that gets printed and flushed from the buffer.