in reply to Re: Re: WRITING TO FILES
in thread Writing to files

Because die() writes its output to STDERR, which is unbuffered. If the script die's with STDOUT buffered (actually, autoflushed) as per normal, then even if you've printed the header, the die message might precede it in the pipe to the server, and that will hose the http message. You must have the http header first, and the way to ensure that is to unbuffer STDOUT. I suppose you could also just write the header to STDERR, but would be, um, less conventional.

jdporter
...porque es dificil estar guapo y blanco.

Replies are listed 'Best First'.
Re: Re: Re: Re: WRITING TO FILES
by chromatic (Archbishop) on Dec 17, 2002 at 22:03 UTC

    Which webserver do you use that sends STDERR to the client?

      I did not say webserver -> client, I said CGI -> webserver. When a (typical) web server spawns the perl process running your CGI script, it collects both STDOUT and STDERR from that process.

      jdporter
      ...porque es dificil estar guapo y blanco.

Re^4: Writing to files
by Aristotle (Chancellor) on Dec 18, 2002 at 01:54 UTC
    What kind of help would writing the header to STDERR be?

    Makeshifts last the longest.