Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Odd behavior: CGI and warnings

by michellem (Friar)
on Oct 30, 2003 at 02:58 UTC ( [id://303183]=perlquestion: print w/replies, xml ) Need Help??

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

Hi fellow Monks,

In finally fixing this problem regarding hanging scripts that have references, I determined exactly what the problem was. Basically, it has to do with warnings. If I have warnings turned off, the script doesn't hang. The problem is that perl is trying to warn me about using an undefined variable in a particular expression - (the one that I had determined was the problem). The strange thing is that the warning never makes it into the error log, and the script just simply hangs.

Has anyone else seen this sort of behavior before? This seems to happen with Apache 2.0, and not 1.3 (I'm using mod_cgi, in these situations). I like to use warnings, it helps me debug, but I've pretty much had to turn them off.

Thanks!

Michelle

Replies are listed 'Best First'.
Re: Odd behavior: CGI and warnings
by mandog (Curate) on Oct 30, 2003 at 03:24 UTC

    Hello MichelleM

    My guess is that either you access your undeclared variable before:

    print "content-type: text/html\n\n";

    ... or that you have troubles with buffering. Generally error messages are flushed right off and other printing is buffered

    This problem would manifest itself in the error log as something line "Premature end of Script Headers "

    This may be clearer if you run your script at the command prompt and your warning comes before your header

    You can turn off buffering by setting  $|=1

    There is a really good nodo on buffering problems: but I can't find it... Suffering from Buffering

    update: there is some apache 2.0 buffering discussion here

      Actually, in this case, it comes after the headers. And running my script at the command line was how I figured out about the issue of warnings, because I was so puzzled. But thanks for the details on buffering, that comes in handy.
Re: Odd behavior: CGI and warnings
by jeffa (Bishop) on Oct 30, 2003 at 03:54 UTC

    I think the key item in your post is Apache 2.0 - isn't it still a bit buggy? Anyways, warnings such as the one you encountered are trivial and usually more of a burden to fix than they are to ignore. However, i really feel compelled to have warning free code, and instead of turning off strict, i would have gotten rid of the warning like so:

    foreach my $record (@records) { foreach my $key (keys %$record) { my $val = $record->{$key} || ''; print "$key:$val"; print $q->br; } }
    However, if you can't even see the warnings, then i would seriously consider just turning warnings off. Actually, i would switch back to Apache 1.3 and wait for Apache 2.1 ;)

    I do know that extremely uses Apache 2.0 - he might be of help to you.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      Thanks jeffa, I like this solution to getting rid of the warning - although I have decided for now to just turn warnings off. I don't really have the option on this server to downgrade to 1.3.
Re: Odd behavior: CGI and warnings
by rdfield (Priest) on Oct 30, 2003 at 09:48 UTC
    In case it's useful: I've never had a problem with warnings using Apache 2.0 with mod_perl (on W2K & RedHat 9.0), rather than Apache 2.0 with mod_cgi. Have you checked to make sure that your logs directory and the error_log is writable by "nobody"?

    rdfield

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://303183]
Approved by mandog
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-26 08:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found