You are seeing the headers in your browser window, indicating that some process has already sent a set of headers to your browser before the headers you are intending
Absolutely correct. CGI::Application has a special method for defining headers; if you don't follow it, it will send 'text/html' as the doctype.
To override the headers, the OP used the appropriate construct:
The only thing I would add is that the CGI::Application POD says that header_props
should be used in conjunction with header_type
do the trick; however, that's the default value.
My only other suggestion to the OP is to look and see if another print statement might be happening somewhere earlier in the process -- try running the application from the command line and look at the output for any whitespace preceding the headers.