suaveant has asked for the wisdom of the Perl Monks concerning the following question:

Color me confused...

I know Fast CGI screws around with STDOUT and STDERR etc in order to do the magic it does, but can someone explain to me why somem this just don't work, such as...

HANDLE = STDOUT; #or even *HANDLE = *STDOUT; print HANDLE "Foo\n";
does not print Foo to STDOUT like a normal script and
open(STDERR, ">>error"); print STDERR "foo\n"; warn "ouchie!";
In normal code you would get all the STDERR stuff in the file error, but in an FCGI it just seems to blackhole... however if we run a command in backticks and it outputs to STDERR, THAT will go into error... it all sees very strange to me... is there some perl magic I can incant to fix this?

                - Ant
                - Some of my best work - Fish Dinner

Replies are listed 'Best First'.
Re: Wierd issues with STDOUT STDERR and FastCGI
by mugwumpjism (Hermit) on Aug 29, 2001 at 01:21 UTC

    I think you need to give FastCGI its own filehandles to play with:

    my $out = new IO::Handle; my $err = new IO::Handle; # keep the environment a global because of CGI.pm my $req = FCGI::Request(\*STDIN, $out, $err, \%ENV); while ($req->Accept() >= 0) { # generate the page select $out; print $page; select STDOUT; }