Hello wise monks, I seek your guidance and wisdom to overcome a wall that I have hit. I am running Perl v.5.12.4 on Mac OS X. My problem is I am creating a script that is accessed via a browser (Safari) that will create and download a CSV file. When I run the script locally, the content of the file is being displayed on the page, and not being downloaded. I have searched high and low, and used the correct headers (as far as I can tell). To troubleshoot, I wanted to see if the browser is accepting any headers, and therefore tested this script (contains no download, just output HTML to the browser):

#!/usr/bin/perl print "Content-type: text/html\n\n"; print "<html><head>"; print "<title>CGI Test</title>"; print "</head>"; print "<body><h2>I just wrote a web page using Perl!</h2>"; print "</body></html>"

The result -- the following is printed on the browser page:

Content-type: text/html <html><head><title>CGI Test</title></head><body><h2>I just wrote a web + page using Perl!</h2></body></html>

It seems that no matter what headers I try, the result is the same -- it is printed to the web page. I cannot for the life of me figure out how to solve this, and therefore graciously request your wisdom. Thank you.


In reply to Print to Browser Headers Not Working by Loops303

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.