By "error bad header" do you mean the typical malformed header error from a CGI program? If that is the case, what is in your error log, what happens when you run the script from the command line, and is the script doing things it needs permission for that the IIS user may not have?
If this is the case, check out the CGI Help Guide and Troubleshooting Perl CGI scripts threads from the Tutorials.